@Test
  public void kmsAeadEncryptAndDecryptWithoutAssociatedData_success() throws Exception {
    KeysetHandle keysetHandle =
        KeysetHandle.generateNew(KmsAeadKeyManager.createKeyTemplate(GCP_KMS_TEST_KEY_URI));
    Aead aead = keysetHandle.getPrimitive(Aead.class);

    byte[] plaintext = "plaintext".getBytes(UTF_8);
    byte[] empty = "".getBytes(UTF_8);
    byte[] ciphertextWithNullAd = aead.encrypt(plaintext, null);
    byte[] ciphertextWithEmptyAd = aead.encrypt(plaintext, empty);

    // Null and empty associated data should be treated the same.
    assertThat(aead.decrypt(ciphertextWithNullAd, null)).isEqualTo(plaintext);
    assertThat(aead.decrypt(ciphertextWithNullAd, empty)).isEqualTo(plaintext);
    assertThat(aead.decrypt(ciphertextWithEmptyAd, null)).isEqualTo(plaintext);
    assertThat(aead.decrypt(ciphertextWithEmptyAd, empty)).isEqualTo(plaintext);
  }
Integration tests for Tink's GcpKmsClient with the real GCP Cloud KMS.
java_src/src/test/java/com/google/crypto/tink/integration/gcpkms/GcpKmsIntegrationTest.java