diff --git a/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/StepsRunnerTest.java b/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/StepsRunnerTest.java index e8a60de2d5..3f41b43c38 100644 --- a/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/StepsRunnerTest.java +++ b/jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/StepsRunnerTest.java @@ -155,8 +155,9 @@ public void testObtainBaseImageLayers_skipObtainingDuplicateLayers() @Test public void testIsImagePushed_skipExistingEnabledAndManifestPresent() { - Optional> manifestResult = Mockito.mock(Optional.class); - Mockito.when(manifestResult.isPresent()).thenReturn(true); + @SuppressWarnings("unchecked") + Optional> manifestResult = + Optional.of(Mockito.mock(ManifestAndDigest.class)); System.setProperty(JibSystemProperties.SKIP_EXISTING_IMAGES, "true"); Assert.assertFalse(stepsRunner.isImagePushed(manifestResult)); @@ -164,7 +165,7 @@ public void testIsImagePushed_skipExistingEnabledAndManifestPresent() { @Test public void testIsImagePushed_skipExistingImageDisabledAndManifestPresent() { - Optional> manifestResult = Mockito.mock(Optional.class); + Optional> manifestResult = Optional.empty(); System.setProperty(JibSystemProperties.SKIP_EXISTING_IMAGES, "false"); Assert.assertTrue(stepsRunner.isImagePushed(manifestResult)); @@ -172,9 +173,8 @@ public void testIsImagePushed_skipExistingImageDisabledAndManifestPresent() { @Test public void testIsImagePushed_skipExistingImageEnabledAndManifestNotPresent() { - Optional> manifestResult = Mockito.mock(Optional.class); + Optional> manifestResult = Optional.empty(); System.setProperty(JibSystemProperties.SKIP_EXISTING_IMAGES, "true"); - Mockito.when(manifestResult.isPresent()).thenReturn(false); Assert.assertTrue(stepsRunner.isImagePushed(manifestResult)); }