### Question:
ManifestListGenerator { public <T extends BuildableManifestTemplate> ManifestTemplate getManifestListTemplate( Class<T> manifestTemplateClass) throws IOException { Preconditions.checkArgument( manifestTemplateClass == V22ManifestTemplate.class, "Build an OCI image index is not yet supported"); Preconditions.checkState(!images.isEmpty(), "no images given"); V22ManifestListTemplate manifestList = new V22ManifestListTemplate(); for (Image image : images) { ImageToJsonTranslator imageTranslator = new ImageToJsonTranslator(image); BlobDescriptor configDescriptor = Digests.computeDigest(imageTranslator.getContainerConfiguration()); BuildableManifestTemplate manifestTemplate = imageTranslator.getManifestTemplate(manifestTemplateClass, configDescriptor); BlobDescriptor manifestDescriptor = Digests.computeDigest(manifestTemplate); ManifestDescriptorTemplate manifest = new ManifestDescriptorTemplate(); manifest.setMediaType(manifestTemplate.getManifestMediaType()); manifest.setSize(manifestDescriptor.getSize()); manifest.setDigest(manifestDescriptor.getDigest().toString()); manifest.setPlatform(image.getArchitecture(), image.getOs()); manifestList.addManifest(manifest); } return manifestList; } ManifestListGenerator(List<Image> images); ManifestTemplate getManifestListTemplate(
      Class<T> manifestTemplateClass);  }### Answer:
@Test public void testGetManifestListTemplate() throws IOException { ManifestTemplate manifestTemplate = manifestListGenerator.getManifestListTemplate(V22ManifestTemplate.class); Assert.assertTrue(manifestTemplate instanceof V22ManifestListTemplate); V22ManifestListTemplate manifestList = (V22ManifestListTemplate) manifestTemplate; Assert.assertEquals(2, manifestList.getSchemaVersion()); Assert.assertEquals( Arrays.asList("sha256:1f25787aab4669d252bdae09a72b9c345d2a7b8c64c8dbfba4c82af4834dbccc"), manifestList.getDigestsForPlatform("amd64", "linux")); Assert.assertEquals( Arrays.asList("sha256:51038a7a91c0e8f747e05dd84c3b0393a7016ec312ce384fc945356778497ae3"), manifestList.getDigestsForPlatform("arm64", "windows")); }
@Test public void testGetManifestListTemplate_emptyImagesList() throws IOException { try { new ManifestListGenerator(Collections.emptyList()) .getManifestListTemplate(V22ManifestTemplate.class); Assert.fail(); } catch (IllegalStateException ex) { Assert.assertEquals("no images given", ex.getMessage()); } }
@Test public void testGetManifestListTemplate_unsupportedImageFormat() throws IOException { try { new ManifestListGenerator(Arrays.asList(image1, image2)) .getManifestListTemplate(OciManifestTemplate.class); Assert.fail(); } catch (IllegalArgumentException ex) { Assert.assertEquals("Build an OCI image index is not yet supported", ex.getMessage()); } }