@Theory
  public void readKeyset_EncryptDecryptDeterministically_success()
      throws Exception {
    KeysetHandle handle =
        TinkJsonProtoKeysetFormat.parseKeyset(JSON_DAEAD_KEYSET, InsecureSecretKeyAccess.get());

    DeterministicAead daead = handle.getPrimitive(DeterministicAead.class);

    byte[] plaintext = "plaintext".getBytes(UTF_8);
    byte[] associatedData = "associatedData".getBytes(UTF_8);
    byte[] ciphertext = daead.encryptDeterministically(plaintext, associatedData);
    byte[] decrypted = daead.decryptDeterministically(ciphertext, associatedData);
    assertThat(decrypted).isEqualTo(plaintext);
  }
Unit tests for the Daead package. Uses only the public API.
java_src/src/test/java/com/google/crypto/tink/daead/DaeadTest.java