public void addManifest(BlobDescriptor descriptor, String imageReferenceName) {
    ManifestDescriptorTemplate contentDescriptorTemplate =
        new ManifestDescriptorTemplate(
            OciManifestTemplate.MANIFEST_MEDIA_TYPE, descriptor.getSize(), descriptor.getDigest());
    contentDescriptorTemplate.setAnnotations(
        ImmutableMap.of("org.opencontainers.image.ref.name", imageReferenceName));
    manifests.add(contentDescriptorTemplate);
  }
@Test
  public void testToJsonWithPlatform() throws DigestException, IOException, URISyntaxException {
    // Loads the expected JSON string.
    Path jsonFile = Paths.get(Resources.getResource("core/json/ociindex_platforms.json").toURI());
    String expectedJson = new String(Files.readAllBytes(jsonFile), StandardCharsets.UTF_8);

    // Creates the JSON object to serialize.
    OciIndexTemplate ociIndexJson = new OciIndexTemplate();

    OciIndexTemplate.ManifestDescriptorTemplate ppc64leManifest =
        new OciIndexTemplate.ManifestDescriptorTemplate(
            OciManifestTemplate.MANIFEST_MEDIA_TYPE,
            7143,
            DescriptorDigest.fromDigest(
                "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f"));
    ppc64leManifest.setPlatform("ppc64le", "linux");
    ociIndexJson.addManifest(ppc64leManifest);

    OciIndexTemplate.ManifestDescriptorTemplate amd64Manifest =
        new OciIndexTemplate.ManifestDescriptorTemplate(
            OciManifestTemplate.MANIFEST_MEDIA_TYPE,
            7682,
            DescriptorDigest.fromDigest(
                "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270"));
    amd64Manifest.setPlatform("amd64", "linux");
    ociIndexJson.addManifest(amd64Manifest);

    // Serializes the JSON object.
    Assert.assertEquals(
        expectedJson.replaceAll("[\r\n\t ]", ""), JsonTemplateMapper.toUtf8String(ociIndexJson));
  }