### Question:
RsaEcdsaHybridEncrypt implements HybridEncrypt { @Override public byte[] encrypt(byte[] plaintext, byte[] contextInfo ) throws GeneralSecurityException { if (contextInfo != null) { throw new GeneralSecurityException("contextInfo must be null because it is unused"); } try { byte[] unsignedCiphertext = HybridRsaUtils.encrypt(plaintext, recipientPublicKey, padding, oaepParameterSpec); return signAndSerialize(unsignedCiphertext); } catch (IOException e) { throw new GeneralSecurityException("encryption failed", e); } } private  RsaEcdsaHybridEncrypt(Builder builder); @Override byte[] encrypt(byte[] plaintext, byte[] contextInfo /* unused */);  }### Answer:
@Test public void testNonNullContextInfo() { HybridEncrypt hybridEncrypt = new RsaEcdsaHybridEncrypt.Builder() .withSenderSigner(senderSigner) .withRecipientPublicKey(recipientPublicKey) .withPadding(Padding.PKCS1) .build(); byte[] plaintext = Random.randBytes(20); byte[] contextInfo = new byte[0]; try { hybridEncrypt.encrypt(plaintext, contextInfo); fail("Expected GeneralSecurityException"); } catch (GeneralSecurityException ex) { } }
@Test public void testEncryptDecrypt() throws IOException, GeneralSecurityException { PublicKeyVerify senderVerifier = TestUtils.createTestSenderVerifier(); PrivateKey recipientPrivateKey = TestUtils.createTestRsaPrivateKey(); for (Padding padding : Padding.values()) { for (int plaintextSize : new int[]{64, 128, 256, 512, 1048}) { byte[] plaintext = Random.randBytes(plaintextSize); HybridEncrypt hybridEncrypt = new RsaEcdsaHybridEncrypt.Builder() .withSenderSigner(senderSigner) .withRecipientPublicKey(recipientPublicKey) .withPadding(padding) .build(); byte[] ciphertext = hybridEncrypt.encrypt(plaintext, null); HybridDecrypt hybridDecrypt = new RsaEcdsaHybridDecrypt.Builder() .withSenderVerifier(senderVerifier) .withRecipientPrivateKey(recipientPrivateKey) .withPadding(padding) .build(); byte[] decryptedPlaintext = hybridDecrypt.decrypt(ciphertext, null); assertArrayEquals(plaintext, decryptedPlaintext); } } }