@Test
  public void getPrimitive_usesProvidedConfigurationWhenProvided() throws Exception {
    PrimitiveRegistry registry =
        PrimitiveRegistry.builder()
            .registerPrimitiveConstructor(
                PrimitiveConstructor.create(
                    KeysetHandleTest::getPrimitiveAHmacKey,
                    HmacKey.class,
                    TestPrimitiveA.class))
            .registerPrimitiveWrapper(new TestWrapperA())
            .build();
    InternalConfiguration configuration =
        InternalConfiguration.createFromPrimitiveRegistry(registry);
    HmacKey hmacKey =
        HmacKey.builder()
            .setParameters(
                HmacParameters.builder()
                    .setKeySizeBytes(20)
                    .setTagSizeBytes(10)
                    .setVariant(HmacParameters.Variant.NO_PREFIX)
                    .setHashType(HmacParameters.HashType.SHA256)
                    .build())
            .setKeyBytes(SecretBytes.randomBytes(20))
            .setIdRequirement(null)
            .build();
    KeysetHandle keysetHandle =
        KeysetHandle.newBuilder()
            .addEntry(KeysetHandle.importKey(hmacKey).withRandomId().makePrimary())
            .build();

    assertThrows(
        GeneralSecurityException.class, () -> keysetHandle.getPrimitive(TestPrimitiveB.class));
    assertThat(keysetHandle.getPrimitive(configuration, TestPrimitiveB.class)).isNotNull();
  }
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