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 testToJson() throws DigestException, IOException, URISyntaxException {
    // Loads the expected JSON string.
    Path jsonFile = Paths.get(Resources.getResource("core/json/ociindex.json").toURI());
    String expectedJson = new String(Files.readAllBytes(jsonFile), StandardCharsets.UTF_8);

    // Creates the JSON object to serialize.
    OciIndexTemplate ociIndexJson = new OciIndexTemplate();
    ociIndexJson.addManifest(
        new BlobDescriptor(
            1000,
            DescriptorDigest.fromDigest(
                "sha256:8c662931926fa990b41da3c9f42663a537ccd498130030f9149173a0493832ad")),
        "regis.try/repo:tag");

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