@Test
  public void testBuilder_multipleKeys() throws Exception {
    KeysetHandle keysetHandle =
        KeysetHandle.newBuilder()
            .addEntry(
                KeysetHandle.generateEntryFromParametersName("AES256_CMAC_RAW")
                    .withRandomId()
                    .setStatus(KeyStatus.DISABLED))
            .addEntry(
                KeysetHandle.generateEntryFromParameters(
                        AesCmacParameters.builder().setKeySizeBytes(32).setTagSizeBytes(10)
                            .setVariant(Variant.CRUNCHY).build())
                    .withRandomId()
                    .makePrimary())
            .addEntry(
                KeysetHandle.generateEntryFromParameters(
                        AesCmacParameters.builder().setKeySizeBytes(32).setTagSizeBytes(13)
                            .setVariant(Variant.LEGACY).build())
                    .withRandomId())
            .build();
    assertThat(keysetHandle.size()).isEqualTo(3);
    KeysetHandle.Entry entry0 = keysetHandle.getAt(0);
    assertThat(entry0.getKey().getParameters())
        .isEqualTo(AesCmacParameters.builder().setKeySizeBytes(32).setTagSizeBytes(16).build());
    assertThat(entry0.isPrimary()).isFalse();
    assertThat(entry0.getStatus()).isEqualTo(KeyStatus.DISABLED);

    KeysetHandle.Entry entry1 = keysetHandle.getAt(1);
    assertThat(entry1.isPrimary()).isTrue();
    assertThat(entry1.getStatus()).isEqualTo(KeyStatus.ENABLED);
    assertThat(entry1.getKey().getParameters())
        .isEqualTo(
            AesCmacParameters.builder().setKeySizeBytes(32).setTagSizeBytes(10)
                .setVariant(Variant.CRUNCHY).build());

    KeysetHandle.Entry entry2 = keysetHandle.getAt(2);
    assertThat(entry2.isPrimary()).isFalse();
    assertThat(entry2.getStatus()).isEqualTo(KeyStatus.ENABLED);
    assertThat(keysetHandle.getAt(2).getKey().getParameters())
        .isEqualTo(
            AesCmacParameters.builder().setKeySizeBytes(32).setTagSizeBytes(13)
                .setVariant(Variant.LEGACY).build());
  }
Tests that key parsing via the serialization registry works as expected.

<p>NOTE: This adds a parser to the MutableSerializationRegistry, which no other test uses.
java_src/src/test/java/com/google/crypto/tink/KeysetHandleTest.java