@Test
  public void parseKey_wrongVersion_throws() throws Exception {
    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().setVersion(1).setParams(format).build().toByteString(),
            KeyMaterialType.REMOTE,
            OutputPrefixType.RAW,
            /* idRequirement= */ null);

    assertThrows(
        GeneralSecurityException.class, () -> registry.parseKey(serialization, /* access= */ null));
  }
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