@VisibleForTesting
  String lookUpPlatformSpecificImageManifest(
      ManifestListTemplate manifestListTemplate, Platform platform)
      throws UnlistedPlatformInManifestListException {
    EventHandlers eventHandlers = buildContext.getEventHandlers();

    List<String> digests =
        manifestListTemplate.getDigestsForPlatform(platform.getArchitecture(), platform.getOs());
    if (digests.isEmpty()) {
      String errorTemplate =
          buildContext.getBaseImageConfiguration().getImage()
              + " is a manifest list, but the list does not contain an image for architecture=%s, "
              + "os=%s. If your intention was to specify a platform for your image, see "
              + "https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#how-do-i-specify-a-platform-in-the-manifest-list-or-oci-index-of-a-base-image";
      String error = String.format(errorTemplate, platform.getArchitecture(), platform.getOs());
      eventHandlers.dispatch(LogEvent.error(error));
      throw new UnlistedPlatformInManifestListException(error);
    }
    // TODO: perhaps we should return multiple digests matching the platform.
    return digests.get(0);
  }
@Test
  public void testLookUpPlatformSpecificOciManifest()
      throws IOException, UnlistedPlatformInManifestListException {
    String manifestListJson =
        " {\n"
            + "   \"schemaVersion\": 2,\n"
            + "   \"mediaType\": \"application/vnd.oci.image.index.v1+json\",\n"
            + "   \"manifests\": [\n"
            + "      {\n"
            + "         \"mediaType\": \"application/vnd.oci.image.manifest.v1+json\",\n"
            + "         \"size\": 424,\n"
            + "         \"digest\": \"sha256:1111111111111111111111111111111111111111111111111111111111111111\",\n"
            + "         \"platform\": {\n"
            + "            \"architecture\": \"arm64\",\n"
            + "            \"os\": \"linux\"\n"
            + "         }\n"
            + "      },\n"
            + "      {\n"
            + "         \"mediaType\": \"application/vnd.oci.image.manifest.v1+json\",\n"
            + "         \"size\": 425,\n"
            + "         \"digest\": \"sha256:2222222222222222222222222222222222222222222222222222222222222222\",\n"
            + "         \"platform\": {\n"
            + "            \"architecture\": \"targetArchitecture\",\n"
            + "            \"os\": \"targetOS\"\n"
            + "         }\n"
            + "      }\n"
            + "   ]\n"
            + "}";

    OciIndexTemplate manifestList =
        JsonTemplateMapper.readJson(manifestListJson, OciIndexTemplate.class);

    String manifestDigest =
        pullBaseImageStep.lookUpPlatformSpecificImageManifest(
            manifestList, new Platform("targetArchitecture", "targetOS"));

    Assert.assertEquals(
        "sha256:2222222222222222222222222222222222222222222222222222222222222222", manifestDigest);
  }