@Test public void shouldUseConnectionForDelete() throws ErrorResultException, LDAPOperationFailedException { String tokenId = "badger"; DN testDN = DN.rootDN(); Connection mockConnection = mock(Connection.class); Result successResult = mockSuccessfulResult(); given(mockConnection.delete(anyString())).willReturn(successResult); TokenAttributeConversion mockConversion = mock(TokenAttributeConversion.class); given(mockConversion.generateTokenDN(anyString())).willReturn(testDN); LDAPAdapter adapter = new LDAPAdapter(mockConversion); adapter.delete(mockConnection, tokenId); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(mockConnection).delete(captor.capture()); assertEquals(String.valueOf(testDN), captor.getValue()); }
public void delete(Connection connection, String tokenId) throws LDAPOperationFailedException, ErrorResultException { String dn = String.valueOf(conversion.generateTokenDN(tokenId)); try { processResult(connection.delete(dn)); } catch (ErrorResultException e) { Result result = e.getResult(); if (e.getResult() != null && ResultCode.NO_SUCH_OBJECT.equals(result.getResultCode())) { return; } throw e; } }
LDAPAdapter { public void delete(Connection connection, String tokenId) throws LDAPOperationFailedException, ErrorResultException { String dn = String.valueOf(conversion.generateTokenDN(tokenId)); try { processResult(connection.delete(dn)); } catch (ErrorResultException e) { Result result = e.getResult(); if (e.getResult() != null && ResultCode.NO_SUCH_OBJECT.equals(result.getResultCode())) { return; } throw e; } } }
LDAPAdapter { public void delete(Connection connection, String tokenId) throws LDAPOperationFailedException, ErrorResultException { String dn = String.valueOf(conversion.generateTokenDN(tokenId)); try { processResult(connection.delete(dn)); } catch (ErrorResultException e) { Result result = e.getResult(); if (e.getResult() != null && ResultCode.NO_SUCH_OBJECT.equals(result.getResultCode())) { return; } throw e; } } @Inject  LDAPAdapter(TokenAttributeConversion conversion); }
LDAPAdapter { public void delete(Connection connection, String tokenId) throws LDAPOperationFailedException, ErrorResultException { String dn = String.valueOf(conversion.generateTokenDN(tokenId)); try { processResult(connection.delete(dn)); } catch (ErrorResultException e) { Result result = e.getResult(); if (e.getResult() != null && ResultCode.NO_SUCH_OBJECT.equals(result.getResultCode())) { return; } throw e; } } @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 delete(Connection connection, String tokenId) throws LDAPOperationFailedException, ErrorResultException { String dn = String.valueOf(conversion.generateTokenDN(tokenId)); try { processResult(connection.delete(dn)); } catch (ErrorResultException e) { Result result = e.getResult(); if (e.getResult() != null && ResultCode.NO_SUCH_OBJECT.equals(result.getResultCode())) { return; } throw e; } } @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);  }