@Test
  @SuppressWarnings("deprecation") // This is a test for the deprecated function
  public void newKey_works() throws Exception {
    HkdfPrfKeyFormat prfKeyFormat =
        HkdfPrfKeyFormat.newBuilder()
            .setKeySize(32)
            .setParams(
                HkdfPrfParams.newBuilder()
                    .setHash(HashType.SHA256)
                    .setSalt(ByteString.copyFrom(new byte[] {1, 2, 3})))
            .build();
    AesGcmKeyFormat format = AesGcmKeyFormat.newBuilder().setKeySize(16).build();
    KeyTemplate derivedKeyTemplate =
        KeyTemplate.newBuilder()
            .setValue(format.toByteString())
            .setTypeUrl("type.googleapis.com/google.crypto.tink.AesGcmKey")
            .setOutputPrefixType(OutputPrefixType.TINK)
            .build();

    PrfBasedDeriverKeyFormat keyFormat =
        PrfBasedDeriverKeyFormat.newBuilder()
            .setPrfKeyTemplate(
                KeyTemplate.newBuilder()
                    .setOutputPrefixType(OutputPrefixType.RAW)
                    .setTypeUrl("type.googleapis.com/google.crypto.tink.HkdfPrfKey")
                    .setValue(prfKeyFormat.toByteString()))
            .setParams(PrfBasedDeriverParams.newBuilder().setDerivedKeyTemplate(derivedKeyTemplate))
            .build();

    PrfBasedDeriverKey prfBasedDeriverKey =
        (PrfBasedDeriverKey) manager.newKey(keyFormat.toByteString());

    assertThat(prfBasedDeriverKey.getParams().getDerivedKeyTemplate())
        .isEqualTo(derivedKeyTemplate);
    assertThat(prfBasedDeriverKey.getPrfKey().getTypeUrl())
        .isEqualTo("type.googleapis.com/google.crypto.tink.HkdfPrfKey");
    assertThat(prfBasedDeriverKey.getPrfKey().getKeyMaterialType())
        .isEqualTo(KeyMaterialType.SYMMETRIC);
    HkdfPrfKey hkdfPrfKey =
        HkdfPrfKey.parseFrom(
            prfBasedDeriverKey.getPrfKey().getValue(), ExtensionRegistryLite.getEmptyRegistry());
    assertThat(hkdfPrfKey.getParams()).isEqualTo(prfKeyFormat.getParams());
    assertThat(hkdfPrfKey.getKeyValue()).hasSize(prfKeyFormat.getKeySize());
  }
We test newKey directly because PrfBasedDeriverKeyManager has its own implementation.
java_src/src/test/java/com/google/crypto/tink/keyderivation/internal/PrfBasedDeriverKeyManagerTest.java