### Question:
PushImageStep implements Callable<BuildResult> { static ImmutableList<PushImageStep> makeListForManifestList( BuildContext buildContext, ProgressEventDispatcher.Factory progressEventDispatcherFactory, RegistryClient registryClient, ManifestTemplate manifestList, boolean manifestListAlreadyExists) throws IOException { Set<String> tags = buildContext.getAllTargetImageTags(); EventHandlers eventHandlers = buildContext.getEventHandlers(); try (TimerEventDispatcher ignored = new TimerEventDispatcher(eventHandlers, "Preparing manifest list pushers"); ProgressEventDispatcher progressEventDispatcher = progressEventDispatcherFactory.create("launching manifest list pushers", tags.size())) { boolean singlePlatform = buildContext.getContainerConfiguration().getPlatforms().size() == 1; if (singlePlatform) { return ImmutableList.of(); } if (JibSystemProperties.skipExistingImages() && manifestListAlreadyExists) { eventHandlers.dispatch(LogEvent.info("Skipping pushing manifest list; already exists.")); return ImmutableList.of(); } DescriptorDigest manifestListDigest = Digests.computeJsonDigest(manifestList); return tags.stream() .map( tag -> new PushImageStep( buildContext, progressEventDispatcher.newChildProducer(), registryClient, manifestList, tag, manifestListDigest, manifestListDigest)) .collect(ImmutableList.toImmutableList()); } } PushImageStep(
      BuildContext buildContext,
      ProgressEventDispatcher.Factory progressEventDispatcherFactory,
      RegistryClient registryClient,
      ManifestTemplate manifestTemplate,
      String imageQualifier,
      DescriptorDigest imageDigest,
      DescriptorDigest imageId); @Override BuildResult call();  }### Answer:
@Test public void testMakeListForManifestList() throws IOException, RegistryException { ImmutableList<PushImageStep> pushImageStepList = PushImageStep.makeListForManifestList( buildContext, progressDispatcherFactory, registryClient, manifestList, false); Assert.assertEquals(2, pushImageStepList.size()); for (PushImageStep pushImageStep : pushImageStepList) { BuildResult buildResult = pushImageStep.call(); Assert.assertEquals( "sha256:64303e82b8a80ef20475dc7f807b81f172cacce1a59191927f3a7ea5222f38ae", buildResult.getImageDigest().toString()); Assert.assertEquals( "sha256:64303e82b8a80ef20475dc7f807b81f172cacce1a59191927f3a7ea5222f38ae", buildResult.getImageId().toString()); } }
@Test public void testMakeListForManifestList_singlePlatform() throws IOException { Mockito.when(containerConfig.getPlatforms()) .thenReturn(ImmutableSet.of(new Platform("amd64", "linux"))); ImmutableList<PushImageStep> pushImageStepList = PushImageStep.makeListForManifestList( buildContext, progressDispatcherFactory, registryClient, manifestList, false); Assert.assertEquals(0, pushImageStepList.size()); }
@Test public void testMakeListForManifestList_manifestListAlreadyExists() throws IOException { System.setProperty(JibSystemProperties.SKIP_EXISTING_IMAGES, "true"); ImmutableList<PushImageStep> pushImageStepList = PushImageStep.makeListForManifestList( buildContext, progressDispatcherFactory, registryClient, manifestList, true); Assert.assertEquals(0, pushImageStepList.size()); }