@Test
  public void serializeParseKey_works() throws Exception {
    LegacyKmsEnvelopeAeadParameters parameters =
        LegacyKmsEnvelopeAeadParameters.builder()
            .setKekUri("someKeyUriForKeyTests")
            .setDekParsingStrategy(
                LegacyKmsEnvelopeAeadParameters.DekParsingStrategy.ASSUME_XCHACHA20POLY1305)
            .setDekParametersForNewKeys(XChaCha20Poly1305Parameters.create())
            .build();
    LegacyKmsEnvelopeAeadKey key = LegacyKmsEnvelopeAeadKey.create(parameters);

    KmsEnvelopeAeadKeyFormat format =
        KmsEnvelopeAeadKeyFormat.newBuilder()
            .setKekUri("someKeyUriForKeyTests")
            .setDekTemplate(
                KeyTemplate.newBuilder()
                    .setTypeUrl("type.googleapis.com/google.crypto.tink.XChaCha20Poly1305Key")
                    .setOutputPrefixType(OutputPrefixType.RAW))
            .build();

    ProtoKeySerialization serialization =
        ProtoKeySerialization.create(
            TYPE_URL,
            KmsEnvelopeAeadKey.newBuilder().setParams(format).build().toByteString(),
            KeyMaterialType.REMOTE,
            OutputPrefixType.RAW,
            /* idRequirement= */ null);

    ProtoKeySerialization serialized =
        registry.serializeKey(key, ProtoKeySerialization.class, /* access= */ null);
    assertEqualWhenValueParsed(KmsEnvelopeAeadKey.parser(), serialized, serialization);

    Key parsed = registry.parseKey(serialization, /* access= */ null);
    assertThat(parsed.equalsKey(key)).isTrue();
  }
Tests that when parsing, the OutputPrefixType of the template in DekKeyTemplate is ignored and
RAW is used instead.
java_src/src/test/java/com/google/crypto/tink/aead/LegacyKmsEnvelopeAeadProtoSerializationTest.java