### Question:
X509AliasKeyManager extends X509ExtendedKeyManager { @Override public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) { return alias; } X509AliasKeyManager(String alias, X509ExtendedKeyManager delegate); @Override String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket); @Override String chooseServerAlias(String keyType, Principal[] issuers, Socket socket); @Override X509Certificate[] getCertificateChain(String alias); @Override String[] getClientAliases(String keyType, Principal[] issuers); @Override PrivateKey getPrivateKey(String alias); @Override String[] getServerAliases(String keyType, Principal[] issuers); @Override String chooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine); @Override String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine);  }### Answer:
@Test public void testChooseServerAliasReturnsGivenAlias() { String wrapperAlias = "wrapperAlias"; String myDelegateAlias = "delegateAlias"; X509ExtendedKeyManager mock = mock(X509ExtendedKeyManager.class); when(mock.chooseServerAlias(any(String.class), any(Principal[].class), any(Socket.class))).thenReturn(myDelegateAlias); X509ExtendedKeyManager wrapper = new X509AliasKeyManager(wrapperAlias, mock); assertEquals("Expected wrapper alias", wrapperAlias, wrapper.chooseServerAlias("", new Principal[0], new Socket())); }