### Question:
KeyPair { public static KeyPair random() { return CryptoEngines.defaultEngine().createKeyGenerator().generateKeyPair(); } private  KeyPair(
      final Optional<PrivateKey> privateKey, final PublicKey publicKey, CryptoEngine engine); static KeyPair random(); static KeyPair random(CryptoEngine engine); static KeyPair fromPrivate(final PrivateKey privateKey, final CryptoEngine engine); static KeyPair onlyPublic(final PublicKey publicKey); static KeyPair onlyPublic(final PublicKey publicKey, final CryptoEngine engine); static KeyPair fromPrivate(final PrivateKey privateKey); PrivateKey getPrivateKey(); PublicKey getPublicKey(); boolean hasPrivateKey();  }### Answer:
@Test void ctorCreatesKeyGenerator() { final KeyPairContext context = new KeyPairContext(); KeyPair.random(context.engine); Mockito.verify(context.engine, Mockito.times(1)).createKeyGenerator(); }
@Test void ctorDelegatesKeyGenerationToKeyGenerator() { final KeyPairContext context = new KeyPairContext(); KeyPair.random(context.engine); Mockito.verify(context.generator, Mockito.times(1)).generateKeyPair(); }