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