@Test
  public void testBuilder_buildTwice_fails() throws Exception {
    KeysetHandle.Builder builder =
        KeysetHandle.newBuilder()
            .addEntry(
                KeysetHandle.generateEntryFromParametersName("AES256_CMAC_RAW")
                    .withRandomId()
                    .makePrimary());

    Object unused = builder.build();
    // We disallow calling build on the same builder twice. The reason is that build assigns IDs
    // which were marked with "withRandomId()". Doing this twice results in incompatible keysets,
    // which would be confusing.
    assertThrows(GeneralSecurityException.class, builder::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