Repository: GoogleContainerTools/jib
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java (Java)

Code before:
import java.nio.file.Paths;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

/** Tests for {@link WarFiles}. */
@RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {

  @Mock private StandardWarExplodedProcessor mockStandardWarExplodedProcessor;

  @Test
  public void testToJibContainerBuilder_explodedStandard_basicInfo()
      throws IOException, InvalidImageReferenceException {
    FileEntriesLayer layer =
        FileEntriesLayer.builder()
            .setName("classes")
            .addEntry(
                Paths.get("path/to/tempDirectory/class1.class"),
                AbsoluteUnixPath.get("/my/app/class1.class"))
            .build();
    when(mockStandardWarExplodedProcessor.createLayers()).thenReturn(Arrays.asList(layer));
    when(mockStandardWarExplodedProcessor.computeEntrypoint(ArgumentMatchers.anyList()))
        .thenReturn(ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar"));

    JibContainerBuilder containerBuilder =
        WarFiles.toJibContainerBuilder(mockStandardWarExplodedProcessor);
    ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();

    assertThat(buildPlan.getBaseImage()).isEqualTo("jetty");
    assertThat(buildPlan.getEntrypoint())
        .isEqualTo(ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar"));
    assertThat(buildPlan.getLayers().size()).isEqualTo(1);
    assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("classes");
    assertThat(((FileEntriesLayer) buildPlan.getLayers().get(0)).getEntries())
        .containsExactlyElementsIn(
            FileEntriesLayer.builder()
                .addEntry(
                    Paths.get("path/to/tempDirectory/class1.class"),
                    AbsoluteUnixPath.get("/my/app/class1.class"))
                .build()
                .getEntries());
  }
}


Review comment (suggestion):
```suggestion
    when(mockStandardWarExplodedProcessor.computeEntrypoint(anyList()))
```

Code after:
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

/** Tests for {@link WarFiles}. */
@RunWith(MockitoJUnitRunner.class)
public class WarFilesTest {

  @Mock private StandardWarExplodedProcessor mockStandardWarExplodedProcessor;

  @Test
  public void testToJibContainerBuilder_explodedStandard_basicInfo()
      throws IOException, InvalidImageReferenceException {
    FileEntriesLayer layer =
        FileEntriesLayer.builder()
            .setName("classes")
            .addEntry(
                Paths.get("path/to/tempDirectory/WEB-INF/classes/class1.class"),
                AbsoluteUnixPath.get("/my/app/WEB-INF/classes/class1.class"))
            .build();
    when(mockStandardWarExplodedProcessor.createLayers()).thenReturn(Arrays.asList(layer));
    when(mockStandardWarExplodedProcessor.computeEntrypoint(anyList()))
        .thenReturn(ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar"));

    JibContainerBuilder containerBuilder =
        WarFiles.toJibContainerBuilder(mockStandardWarExplodedProcessor);
    ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();

    assertThat(buildPlan.getBaseImage()).isEqualTo("jetty");
    assertThat(buildPlan.getEntrypoint())
        .containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
        .inOrder();
    assertThat(buildPlan.getLayers()).hasSize(1);
    assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("classes");
    assertThat(((FileEntriesLayer) buildPlan.getLayers().get(0)).getEntries())
        .containsExactlyElementsIn(
            FileEntriesLayer.builder()
                .addEntry(
                    Paths.get("path/to/tempDirectory/WEB-INF/classes/class1.class"),
                    AbsoluteUnixPath.get("/my/app/WEB-INF/classes/class1.class"))
                .build()
                .getEntries());
  }
}