private void testContext(byte[] mode, byte[] kemId, byte[] kdfId, byte[] aeadId)
      throws GeneralSecurityException {
    HpkeTestVector testVector = getTestVector(mode, kemId, kdfId, aeadId);
    HpkeTestSetup testSetup = testVector.getTestSetup();

    HpkeKem kem = HpkePrimitiveFactory.createKem(kemId);
    HpkeKdf kdf = HpkePrimitiveFactory.createKdf(kdfId);
    HpkeAead aead = HpkePrimitiveFactory.createAead(aeadId);

    HpkeContext encryptionContext =
        HpkeContext.createContext(
            mode,
            testSetup.encapsulatedKey,
            testSetup.sharedSecret,
            kem,
            kdf,
            aead,
            testSetup.info);
    verifyContext(encryptionContext, testVector);
    verifyEncrypt(encryptionContext, testVector);

    HpkeContext decryptionContext =
        HpkeContext.createContext(
            mode,
            testSetup.encapsulatedKey,
            testSetup.sharedSecret,
            kem,
            kdf,
            aead,
            testSetup.info);
    verifyContext(decryptionContext, testVector);
    verifyDecrypt(decryptionContext, testVector);
  }
Helper method to verify context against test vectors provided in HPKE I.-D.
java_src/src/test/java/com/google/crypto/tink/hybrid/internal/HpkeContextTest.java