### Question:
LdapAdapter implements TokenStorageAdapter<Connection> { public boolean update(Connection connection, Token previous, Token updated) throws LdapOperationFailedException { Entry currentEntry = conversion.getEntry(updated); LdapTokenAttributeConversion.stripObjectClass(currentEntry); Entry previousEntry = conversion.getEntry(previous); LdapTokenAttributeConversion.stripObjectClass(previousEntry); ModifyRequest request = Entries.diffEntries(previousEntry, currentEntry, Entries.diffOptions().replaceSingleValuedAttributes()); request.addControl(TransactionIdControl.newControl(AuditRequestContext.createSubTransactionIdValue())); if (request.getModifications().isEmpty()) { return false; } try { processResult(connection.modify(request)); } catch (LdapException e) { throw new LdapOperationFailedException(e.getResult()); } return true; } @Inject  LdapAdapter(LdapTokenAttributeConversion conversion, LdapQueryFilterVisitor queryConverter,
            LdapQueryFactory queryFactory); 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); @Override Collection<Token> query(Connection connection, TokenFilter query); @Override Collection<PartialToken> partialQuery(Connection connection, TokenFilter query);  }### Answer:
@Test public void shouldNoNothingIfNoModificaitonsOnUpdate() throws Exception { String tokenId = "badger"; Token first = new Token(tokenId, TokenType.OAUTH); Token second = new Token(tokenId, TokenType.OAUTH); Connection mockConnection = mock(Connection.class); LdapDataLayerConfiguration config = mock(LdapDataLayerConfiguration.class); when(config.getTokenStoreRootSuffix()).thenReturn(DN.valueOf("ou=unit-test")); LDAPDataConversion dataConversion = new LDAPDataConversion(); LdapTokenAttributeConversion conversion = new LdapTokenAttributeConversion(dataConversion, config); adapter = new LdapAdapter(conversion, mockQueryVisitor, mockQueryFactory); adapter.update(mockConnection, first, second); verify(mockConnection, never()).modify(any(ModifyRequest.class)); }
@Test public void shouldPerformUpdate() throws Exception { Token first = new Token("weasel", TokenType.OAUTH); Token second = new Token("badger", TokenType.OAUTH); Connection mockConnection = mock(Connection.class); Result successResult = mockSuccessfulResult(); given(mockConnection.modify(any(ModifyRequest.class))).willReturn(successResult); LdapDataLayerConfiguration config = mock(LdapDataLayerConfiguration.class); when(config.getTokenStoreRootSuffix()).thenReturn(DN.valueOf("ou=unit-test")); LDAPDataConversion dataConversion = new LDAPDataConversion(); LdapTokenAttributeConversion conversion = new LdapTokenAttributeConversion(dataConversion, config); LdapAdapter adapter = new LdapAdapter(conversion, null, null); adapter.update(mockConnection, first, second); verify(mockConnection).modify(any(ModifyRequest.class)); }