Repository: GoogleContainerTools/jib
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/JibExtensionTest.java (Java)

Code before:
  public void testToTags_containsNullTag() {
    TargetImageParameters testToParameters = generateTargetImageParametersWithTags(null, "tag1");
    Exception exception =
        assertThrows(IllegalArgumentException.class, () -> testToParameters.getTags());
    assertThat(exception).hasMessageThat().isEqualTo("jib.to.tags contains null tag");
  }

  @Test
  public void testToTags_containsEmptyTag() {
    TargetImageParameters testToParameters = generateTargetImageParametersWithTags("", "tag1");
    Exception exception =
        assertThrows(IllegalArgumentException.class, () -> testToParameters.getTags());
    assertThat(exception).hasMessageThat().isEqualTo("jib.to.tags contains empty tag");
  }

  @Test
  public void testContainer() {
    assertThat(testJibExtension.getContainer().getJvmFlags()).isEmpty();
    assertThat(testJibExtension.getContainer().getEnvironment()).isEmpty();
    assertThat(testJibExtension.getContainer().getExtraClasspath()).isEmpty();
    assertThat(testJibExtension.getContainer().getExpandClasspathDependencies()).isFalse();
    assertThat(testJibExtension.getContainer().getMainClass()).isNull();
    assertThat(testJibExtension.getContainer().getArgs()).isNull();
    assertThat(testJibExtension.getContainer().getFormat()).isSameInstanceAs(ImageFormat.Docker);
    assertThat(testJibExtension.getContainer().getPorts()).isEmpty();
    assertThat(testJibExtension.getContainer().getAppRoot()).isEmpty();
    assertThat(testJibExtension.getContainer().getFilesModificationTime())
        .isEqualTo("EPOCH_PLUS_SECOND");
    assertThat(testJibExtension.getContainer().getCreationTime()).isEqualTo("EPOCH");

    testJibExtension.container(
        container -> {
          container.setJvmFlags(Arrays.asList("jvmFlag1", "jvmFlag2"));
          container.setEnvironment(ImmutableMap.of("var1", "value1", "var2", "value2"));
          container.setEntrypoint(Arrays.asList("foo", "bar", "baz"));
          container.setExtraClasspath(Arrays.asList("/d1", "/d2", "/d3"));
          container.setExpandClasspathDependencies(true);
          container.setMainClass("mainClass");
          container.setArgs(Arrays.asList("arg1", "arg2", "arg3"));
          container.setPorts(Arrays.asList("1000", "2000-2010", "3000"));
          container.setFormat(ImageFormat.OCI);
          container.setAppRoot("some invalid appRoot value");
          container.setFilesModificationTime("some invalid time value");
        });
    ContainerParameters container = testJibExtension.getContainer();
    assertThat(container.getEntrypoint()).containsExactly("foo", "bar", "baz").inOrder();
    assertThat(container.getJvmFlags()).containsExactly("jvmFlag1", "jvmFlag2").inOrder();
    assertThat(container.getEnvironment())
        .containsExactly("var1", "value1", "var2", "value2")
        .inOrder();
    assertThat(container.getExtraClasspath()).containsExactly("/d1", "/d2", "/d3").inOrder();

Review comment (suggestion):
Checking this seems meaningful. Maybe this can be
```
assertThat(testJibExtension.getContainer().getLabels().get()).isEmpty();
```

Code after:
  public void testToTags_containsNullTag() {
    TargetImageParameters testToParameters = generateTargetImageParametersWithTags(null, "tag1");
    Exception exception =
        assertThrows(IllegalArgumentException.class, () -> testToParameters.getTags());
    assertThat(exception).hasMessageThat().isEqualTo("jib.to.tags contains null tag");
  }

  @Test
  public void testToTags_containsEmptyTag() {
    TargetImageParameters testToParameters = generateTargetImageParametersWithTags("", "tag1");
    Exception exception =
        assertThrows(IllegalArgumentException.class, () -> testToParameters.getTags());
    assertThat(exception).hasMessageThat().isEqualTo("jib.to.tags contains empty tag");
  }

  @Test
  public void testContainer() {
    assertThat(testJibExtension.getContainer().getJvmFlags()).isEmpty();
    assertThat(testJibExtension.getContainer().getEnvironment()).isEmpty();
    assertThat(testJibExtension.getContainer().getExtraClasspath()).isEmpty();
    assertThat(testJibExtension.getContainer().getExpandClasspathDependencies()).isFalse();
    assertThat(testJibExtension.getContainer().getMainClass()).isNull();
    assertThat(testJibExtension.getContainer().getArgs()).isNull();
    assertThat(testJibExtension.getContainer().getFormat()).isSameInstanceAs(ImageFormat.Docker);
    assertThat(testJibExtension.getContainer().getPorts()).isEmpty();
    assertThat(testJibExtension.getContainer().getLabels().get()).isEmpty();
    assertThat(testJibExtension.getContainer().getAppRoot()).isEmpty();
    assertThat(testJibExtension.getContainer().getFilesModificationTime())
        .isEqualTo("EPOCH_PLUS_SECOND");
    assertThat(testJibExtension.getContainer().getCreationTime()).isEqualTo("EPOCH");

    testJibExtension.container(
        container -> {
          container.setJvmFlags(Arrays.asList("jvmFlag1", "jvmFlag2"));
          container.setEnvironment(ImmutableMap.of("var1", "value1", "var2", "value2"));
          container.setEntrypoint(Arrays.asList("foo", "bar", "baz"));
          container.setExtraClasspath(Arrays.asList("/d1", "/d2", "/d3"));
          container.setExpandClasspathDependencies(true);
          container.setMainClass("mainClass");
          container.setArgs(Arrays.asList("arg1", "arg2", "arg3"));
          container.setPorts(Arrays.asList("1000", "2000-2010", "3000"));
          container.setFormat(ImageFormat.OCI);
          container.setAppRoot("some invalid appRoot value");
          container.setFilesModificationTime("some invalid time value");
        });
    ContainerParameters container = testJibExtension.getContainer();
    assertThat(container.getEntrypoint()).containsExactly("foo", "bar", "baz").inOrder();
    assertThat(container.getJvmFlags()).containsExactly("jvmFlag1", "jvmFlag2").inOrder();
    assertThat(container.getEnvironment())
        .containsExactly("var1", "value1", "var2", "value2")
        .inOrder();