@Test public void shouldUseConnectionForCreate() throws LDAPOperationFailedException, ErrorResultException { Token token = new Token("badger", TokenType.SESSION); Connection mockConnection = mock(Connection.class); Result successResult = mockSuccessfulResult(); given(mockConnection.add(any(Entry.class))).willReturn(successResult); TokenAttributeConversion mockConversion = mock(TokenAttributeConversion.class); given(mockConversion.getEntry(any(Token.class))).willReturn(mock(Entry.class)); LDAPAdapter adapter = new LDAPAdapter(mockConversion); adapter.create(mockConnection, token); verify(mockConnection).add(any(Entry.class)); }
public void create(Connection connection, Token token) throws ErrorResultException, LDAPOperationFailedException { Entry entry = conversion.getEntry(token); processResult(connection.add(entry)); }
LDAPAdapter { public void create(Connection connection, Token token) throws ErrorResultException, LDAPOperationFailedException { Entry entry = conversion.getEntry(token); processResult(connection.add(entry)); } }
LDAPAdapter { public void create(Connection connection, Token token) throws ErrorResultException, LDAPOperationFailedException { Entry entry = conversion.getEntry(token); processResult(connection.add(entry)); } @Inject  LDAPAdapter(TokenAttributeConversion conversion); }
LDAPAdapter { public void create(Connection connection, Token token) throws ErrorResultException, LDAPOperationFailedException { Entry entry = conversion.getEntry(token); processResult(connection.add(entry)); } @Inject  LDAPAdapter(TokenAttributeConversion conversion); void create(Connection connection, Token token); Token read(Connection connection,  String tokenId); boolean update(Connection connection, Token previous, Token updated); void delete(Connection connection, String tokenId); void deleteAsync(Connection connection, String tokenId, ResultHandler<Result> handler); }
LDAPAdapter { public void create(Connection connection, Token token) throws ErrorResultException, LDAPOperationFailedException { Entry entry = conversion.getEntry(token); processResult(connection.add(entry)); } @Inject  LDAPAdapter(TokenAttributeConversion conversion); void create(Connection connection, Token token); Token read(Connection connection,  String tokenId); boolean update(Connection connection, Token previous, Token updated); void delete(Connection connection, String tokenId); void deleteAsync(Connection connection, String tokenId, ResultHandler<Result> handler);  }