SSLLdapConnectionFactory implements LdapConnectionFactory { public LDAPConnection buildLdapConnection() throws GeneralSecurityException, LDAPException { SSLSocketFactory sslSocketFactory = SSL_UTIL.createSSLSocketFactory(); return new LDAPConnection(sslSocketFactory, ldapProperties.getHost(), ldapProperties.getPort()); } SSLLdapConnectionFactory(final LdapProperties ldapProperties); LDAPConnection buildLdapConnection();  }
@Test public void shouldTryToBuildLdapConnection() { final LdapProperties properties = mock(LdapProperties.class); when(properties.getHost()).thenReturn("foo"); when(properties.getPort()).thenReturn(42); assertThrows(LDAPException.class, () -> { new SSLLdapConnectionFactory(properties).buildLdapConnection(); }); }