@Override
  public ManifestTemplate call() throws IOException {
    Preconditions.checkState(!builtImages.isEmpty(), "no images given");
    EventHandlers eventHandlers = buildContext.getEventHandlers();
    try (TimerEventDispatcher ignored = new TimerEventDispatcher(eventHandlers, DESCRIPTION);
        ProgressEventDispatcher ignored2 =
            progressEventDispatcherFactory.create(
                "building a manifest list or a single manifest", 1)) {

      if (builtImages.size() == 1) {
        eventHandlers.dispatch(LogEvent.info("Building a single manifest"));
        ImageToJsonTranslator imageTranslator = new ImageToJsonTranslator(builtImages.get(0));
        BlobDescriptor configDescriptor =
            Digests.computeDigest(imageTranslator.getContainerConfiguration());
        return imageTranslator.getManifestTemplate(
            buildContext.getTargetFormat(), configDescriptor);
      }

      eventHandlers.dispatch(LogEvent.info("Building a manifest list"));
      return new ManifestListGenerator(builtImages)
          .getManifestListTemplate(buildContext.getTargetFormat());
    }
  }
@Test
  public void testCall_singleManifest() throws IOException {

    // Expected manifest JSON
    //  {
    //  "schemaVersion":2,
    //  "mediaType":"application/vnd.docker.distribution.manifest.v2+json",
    //  "config":{
    //    "mediaType":"application/vnd.docker.container.image.v1+json",
    //    "digest":"sha256:1b2ff280940537177565443144a81319ad48528fd35d1cdc38cbde07f24f6912",
    //    "size":158
    //  },
    //  "layers":[
    //    {
    //      "mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip",
    //      "size":0
    //    }
    //  ]
    // }

    ManifestTemplate manifestTemplate =
        new BuildManifestListOrSingleManifestStep(
                buildContext, progressDispatcherFactory, Arrays.asList(image1))
            .call();

    Assert.assertTrue(manifestTemplate instanceof V22ManifestTemplate);
    V22ManifestTemplate manifest = (V22ManifestTemplate) manifestTemplate;
    Assert.assertEquals(2, manifest.getSchemaVersion());
    Assert.assertEquals(
        "application/vnd.docker.distribution.manifest.v2+json", manifest.getManifestMediaType());
    Assert.assertEquals(
        "sha256:1b2ff280940537177565443144a81319ad48528fd35d1cdc38cbde07f24f6912",
        manifest.getContainerConfiguration().getDigest().toString());
    Assert.assertEquals(0, manifest.getLayers().get(0).getSize());
    Assert.assertEquals(158, manifest.getContainerConfiguration().getSize());
  }