@Test public void shouldReadToken() throws CoreTokenException, ErrorResultException { String tokenId = "badger"; Token token = new Token(tokenId, TokenType.SESSION); given(mockLDAPAdapter.read(any(Connection.class), eq(tokenId))).willReturn(token); Token result = adapter.read(tokenId); assertThat(result.getTokenId()).isEqualTo(tokenId); }
public Token read(String tokenId) throws CoreTokenException { Connection connection = null; try { connection = connectionFactory.getConnection(); Token token = ldapAdapter.read(connection, tokenId); if (token == null) { if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} not found.", tokenId)); } return null; } if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} successfully.", tokenId)); } return token; } catch (ErrorResultException e) { Result result = e.getResult(); throw new LDAPOperationFailedException(result); } finally { IOUtils.closeIfNotNull(connection); } }
CoreTokenAdapter { public Token read(String tokenId) throws CoreTokenException { Connection connection = null; try { connection = connectionFactory.getConnection(); Token token = ldapAdapter.read(connection, tokenId); if (token == null) { if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} not found.", tokenId)); } return null; } if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} successfully.", tokenId)); } return token; } catch (ErrorResultException e) { Result result = e.getResult(); throw new LDAPOperationFailedException(result); } finally { IOUtils.closeIfNotNull(connection); } } }
CoreTokenAdapter { public Token read(String tokenId) throws CoreTokenException { Connection connection = null; try { connection = connectionFactory.getConnection(); Token token = ldapAdapter.read(connection, tokenId); if (token == null) { if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} not found.", tokenId)); } return null; } if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} successfully.", tokenId)); } return token; } catch (ErrorResultException e) { Result result = e.getResult(); throw new LDAPOperationFailedException(result); } finally { IOUtils.closeIfNotNull(connection); } } @Inject  CoreTokenAdapter(ConnectionFactory connectionFactory, QueryFactory queryFactory,
                            LDAPAdapter ldapAdapter, ConfigurationObserver observer,
                            CoreTokenConfigListener listener, @Named(CoreTokenConstants.CTS_DEBUG) Debug debug); }
CoreTokenAdapter { public Token read(String tokenId) throws CoreTokenException { Connection connection = null; try { connection = connectionFactory.getConnection(); Token token = ldapAdapter.read(connection, tokenId); if (token == null) { if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} not found.", tokenId)); } return null; } if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} successfully.", tokenId)); } return token; } catch (ErrorResultException e) { Result result = e.getResult(); throw new LDAPOperationFailedException(result); } finally { IOUtils.closeIfNotNull(connection); } } @Inject  CoreTokenAdapter(ConnectionFactory connectionFactory, QueryFactory queryFactory,
                            LDAPAdapter ldapAdapter, ConfigurationObserver observer,
                            CoreTokenConfigListener listener, @Named(CoreTokenConstants.CTS_DEBUG) Debug debug); void create(Token token); Token read(String tokenId); QueryBuilder query(); QueryFilter buildFilter(); void updateOrCreate(Token token); void delete(String tokenId); }
CoreTokenAdapter { public Token read(String tokenId) throws CoreTokenException { Connection connection = null; try { connection = connectionFactory.getConnection(); Token token = ldapAdapter.read(connection, tokenId); if (token == null) { if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} not found.", tokenId)); } return null; } if (debug.messageEnabled()) { debug.message(MessageFormat.format( CoreTokenConstants.DEBUG_HEADER + "Read: {0} successfully.", tokenId)); } return token; } catch (ErrorResultException e) { Result result = e.getResult(); throw new LDAPOperationFailedException(result); } finally { IOUtils.closeIfNotNull(connection); } } @Inject  CoreTokenAdapter(ConnectionFactory connectionFactory, QueryFactory queryFactory,
                            LDAPAdapter ldapAdapter, ConfigurationObserver observer,
                            CoreTokenConfigListener listener, @Named(CoreTokenConstants.CTS_DEBUG) Debug debug); void create(Token token); Token read(String tokenId); QueryBuilder query(); QueryFilter buildFilter(); void updateOrCreate(Token token); void delete(String tokenId);  }