### Question:
LdapProtocolFactory { public LdapProtocol createLdapProtocol( IVariables variables, ILdapMeta meta, Collection<String> binaryAttributes ) throws HopException { String connectionType = variables.environmentSubstitute( meta.getProtocol() ); synchronized ( protocols ) { for ( Class<? extends LdapProtocol> protocol : protocols ) { if ( getName( protocol ).equals( connectionType ) ) { try { return protocol.getConstructor( ILogChannel.class, IVariables.class, ILdapMeta.class, Collection.class ).newInstance( log, variables, meta, binaryAttributes ); } catch ( Exception e ) { throw new HopException( e ); } } } } return null; } LdapProtocolFactory( ILogChannel log ); static final List<String> getConnectionTypes( ILogChannel log ); LdapProtocol createLdapProtocol( IVariables variables, ILdapMeta meta,
                                          Collection<String> binaryAttributes );  }### Answer:
@Test public void createLdapProtocol() throws Exception { String ldapVariable = "${ldap_protocol_variable}"; String ldap = "LDAP"; String host = "localhost"; LdapProtocolFactory ldapProtocolFactory = new LdapProtocolFactory( Mockito.mock( ILogChannel.class ) ); IVariables variables = Mockito.mock( IVariables.class ); ILdapMeta meta = Mockito.mock( ILdapMeta.class ); Mockito.doReturn( ldapVariable ).when( meta ).getProtocol(); Mockito.doReturn( ldap ).when( variables ).environmentSubstitute( ldapVariable ); Mockito.doReturn( host ).when( meta ).getHost(); Mockito.doReturn( host ).when( variables ).environmentSubstitute( host ); ldapProtocolFactory.createLdapProtocol( variables, meta, Collections.emptyList() ); Mockito.verify( variables, Mockito.times( 1 ) ).environmentSubstitute( ldapVariable ); }