@Test
  public void createPrimitiveAndUseIt_works() throws Exception {
    // Test vector from PrfBasedDeriverSecondTest. (FIXED_PRF_KEY)
    PrfKey prfKey =
        com.google.crypto.tink.prf.HkdfPrfKey.builder()
            .setParameters(
                HkdfPrfParameters.builder()
                    .setKeySizeBytes(32)
                    .setHashType(HkdfPrfParameters.HashType.SHA256)
                    .build())
            .setKeyBytes(
                SecretBytes.copyFrom(
                    Hex.decode("0102030405060708091011121314151617181920212123242526272829303132"),
                    InsecureSecretKeyAccess.get()))
            .build();

    PrfBasedKeyDerivationParameters derivationParameters =
        PrfBasedKeyDerivationParameters.builder()
            .setDerivedKeyParameters(PredefinedAeadParameters.AES128_GCM)
            .setPrfParameters(prfKey.getParameters())
            .build();
    PrfBasedKeyDerivationKey keyDerivationKey =
        PrfBasedKeyDerivationKey.create(derivationParameters, prfKey, 123);

    KeysetHandle handle =
        KeysetHandle.newBuilder()
            .addEntry(KeysetHandle.importKey(keyDerivationKey).makePrimary().withFixedId(123))
            .build();
    KeysetDeriver deriver = handle.getPrimitive(KeysetDeriver.class);

    Key expectedKey =
        AesGcmKey.builder()
            .setParameters(PredefinedAeadParameters.AES128_GCM)
            .setIdRequirement(123)
            .setKeyBytes(
                SecretBytes.copyFrom(
                    Hex.decode("1b73bdf5293cc533d635f263e35913ec"), InsecureSecretKeyAccess.get()))
            .build();
    KeysetHandle derivedKeysetHandle = deriver.deriveKeyset(new byte[0]);
    assertThat(derivedKeysetHandle.getAt(0).getKey().getParameters())
        .isEqualTo(PredefinedAeadParameters.AES128_GCM);
    assertThat(derivedKeysetHandle.getAt(0).getKey().equalsKey(expectedKey)).isTrue();
  }
We test newKeyData directly because PrfBasedDeriverKeyManager has its own implementation.
java_src/src/test/java/com/google/crypto/tink/keyderivation/internal/PrfBasedDeriverKeyManagerTest.java