test_class.declarator: KEY_ID = "123"
test_class.modifier: private static final
test_class.original_string: private static final String KEY_ID = "123";
test_class.type: String
test_class.var_name: KEY_ID
test_class.declarator: mockKms
test_class.modifier: @Mock private
test_class.original_string: @Mock private AWSKMS mockKms;
test_class.type: AWSKMS
test_class.var_name: mockKms
test_class.file: java_src/src/test/java/com/google/crypto/tink/integration/awskms/AwsKmsAeadTest.java
test_class.identifier: AwsKmsAeadTest
test_case.body: @Test
    public void testEncryptShouldThrowExceptionIfRequestFailed() throws Exception {
      AmazonServiceException exception = mock(AmazonServiceException.class);
      when(mockKms.encrypt(isA(EncryptRequest.class)))
          .thenThrow(exception);
  
      Aead aead = new AwsKmsAead(mockKms, KEY_ID);
      byte[] aad = Random.randBytes(20);
      byte[] message = Random.randBytes(20);
      try {
        aead.encrypt(message, aad);
        fail("Expected GeneralSecurityException");
      } catch (GeneralSecurityException e) {
        // expected.
      }
    }
test_case.class_method_signature: AwsKmsAeadTest.testEncryptShouldThrowExceptionIfRequestFailed()
test_case.full_signature: @Test public void testEncryptShouldThrowExceptionIfRequestFailed()
test_case.identifier: testEncryptShouldThrowExceptionIfRequestFailed
test_case.invocations: mock thenThrow when encrypt isA randBytes randBytes encrypt fail
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEncryptShouldThrowExceptionIfRequestFailed()
focal_class.declarator: kmsClient
focal_class.modifier: private final
focal_class.original_string: private final AWSKMS kmsClient;
focal_class.type: AWSKMS
focal_class.var_name: kmsClient
focal_class.declarator: keyArn
focal_class.modifier: private final
focal_class.original_string: private final String keyArn;
focal_class.type: String
focal_class.var_name: keyArn
focal_class.file: java_src/src/main/java/com/google/crypto/tink/integration/awskms/AwsKmsAead.java
focal_class.identifier: AwsKmsAead
focal_class.interfaces: implements Aead
focal_class.class_method_signature: AwsKmsAead.AwsKmsAead(AWSKMS kmsClient, String keyUri)
focal_class.full_signature: public  AwsKmsAead(AWSKMS kmsClient, String keyUri)
focal_class.identifier: AwsKmsAead
focal_class.modifiers: public
focal_class.parameters: (AWSKMS kmsClient, String keyUri)
focal_class.signature:  AwsKmsAead(AWSKMS kmsClient, String keyUri)
focal_class.class_method_signature: AwsKmsAead.encrypt(final byte[] plaintext, final byte[] associatedData)
focal_class.full_signature: @Override public byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
focal_class.identifier: encrypt
focal_class.modifiers: @Override public
focal_class.parameters: (final byte[] plaintext, final byte[] associatedData)
focal_class.return: byte[]
focal_class.signature: byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
focal_class.class_method_signature: AwsKmsAead.decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_class.full_signature: @Override public byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_class.identifier: decrypt
focal_class.modifiers: @Override public
focal_class.parameters: (final byte[] ciphertext, final byte[] associatedData)
focal_class.return: byte[]
focal_class.signature: byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_method.body: @Override
    public byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
        throws GeneralSecurityException {
      try {
        EncryptRequest req =
            new EncryptRequest().withKeyId(keyArn).withPlaintext(ByteBuffer.wrap(plaintext));
        if (associatedData != null && associatedData.length != 0) {
          req = req.addEncryptionContextEntry("associatedData", BinaryUtils.toHex(associatedData));
        }
        return kmsClient.encrypt(req).getCiphertextBlob().array();
      } catch (AmazonServiceException e) {
        throw new GeneralSecurityException("encryption failed", e);
      }
    }
focal_method.class_method_signature: AwsKmsAead.encrypt(final byte[] plaintext, final byte[] associatedData)
focal_method.full_signature: @Override public byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
focal_method.identifier: encrypt
focal_method.invocations: withPlaintext withKeyId wrap addEncryptionContextEntry toHex array getCiphertextBlob encrypt
focal_method.modifiers: @Override public
focal_method.parameters: (final byte[] plaintext, final byte[] associatedData)
focal_method.return: byte[]
focal_method.signature: byte[] encrypt(final byte[] plaintext, final byte[] associatedData)