diff --git a/core/src/main/java/org/testcontainers/utility/TestcontainersConfiguration.java b/core/src/main/java/org/testcontainers/utility/TestcontainersConfiguration.java index 18cfdaff303..e52a8be7297 100644 --- a/core/src/main/java/org/testcontainers/utility/TestcontainersConfiguration.java +++ b/core/src/main/java/org/testcontainers/utility/TestcontainersConfiguration.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.exception.ExceptionUtils; import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.testcontainers.UnstableAPI; @@ -186,7 +187,7 @@ public Integer getImagePullPauseTimeout() { */ @Nullable @Contract("_, !null -> !null") - public String getEnvVarOrProperty(final String propertyName, @Nullable final String defaultValue) { + public String getEnvVarOrProperty(@NotNull final String propertyName, @Nullable final String defaultValue) { String envVarName = propertyName.replaceAll("\\.", "_").toUpperCase(); if (!propertyName.startsWith("TESTCONTAINERS_")) { envVarName = "TESTCONTAINERS_" + envVarName; diff --git a/core/src/test/java/org/testcontainers/utility/PrefixingImageNameSubstitutorTest.java b/core/src/test/java/org/testcontainers/utility/PrefixingImageNameSubstitutorTest.java index 0b0328b1890..3e6675660cf 100644 --- a/core/src/test/java/org/testcontainers/utility/PrefixingImageNameSubstitutorTest.java +++ b/core/src/test/java/org/testcontainers/utility/PrefixingImageNameSubstitutorTest.java @@ -3,6 +3,7 @@ import org.junit.Before; import org.junit.Test; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -22,7 +23,7 @@ public void setUp() { @Test public void testHappyPath() { - when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY))).thenReturn("someregistry.com/"); + when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY), any())).thenReturn("someregistry.com/"); final DockerImageName result = underTest.apply(DockerImageName.parse("some/image:tag")); @@ -35,7 +36,7 @@ public void testHappyPath() { @Test public void testNoDoublePrefixing() { - when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY))).thenReturn("someregistry.com/"); + when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY), any())).thenReturn("someregistry.com/"); final DockerImageName result = underTest.apply(DockerImageName.parse("someregistry.com/some/image:tag")); @@ -48,7 +49,7 @@ public void testNoDoublePrefixing() { @Test public void testHandlesNullValue() { - when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY))).thenReturn(null); + when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY), any())).thenReturn(null); final DockerImageName result = underTest.apply(DockerImageName.parse("some/image:tag")); @@ -61,7 +62,7 @@ public void testHandlesNullValue() { @Test public void testHandlesEmptyValue() { - when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY))).thenReturn(""); + when(mockConfiguration.getEnvVarOrProperty(eq(PROPERTY_KEY), any())).thenReturn(""); final DockerImageName result = underTest.apply(DockerImageName.parse("some/image:tag"));