@Test public void shouldUseSessionQueryTypeProvidedByFactory() { SessionQueryType mockQueryType = mock(SessionQueryType.class); SessionQueryFactory mockFactory = mock(SessionQueryFactory.class); given(mockFactory.getSessionQueryType(anyString())).willReturn(mockQueryType); SessionQueryManager manager = new SessionQueryManager(mockFactory); manager.getAllSessions(Arrays.asList(new String[]{"badger"})); verify(mockQueryType, times(1)).getAllSessions(); }
public Collection<SessionInfo> getAllSessions(Collection<String> serverIds) { List<SessionInfo> sessions = new LinkedList<SessionInfo>(); for (String server : serverIds) { SessionQueryType queryType = queryFactory.getSessionQueryType(server); Collection<SessionInfo> queriedSessions = queryType.getAllSessions(); if (debug.messageEnabled()) { debug.message(MessageFormat.format( "SessionQueryManager#getAllSessions() :: Queried {0} from: {1}", queriedSessions.size(), server)); } sessions.addAll(queriedSessions); } return sessions; }
SessionQueryManager { public Collection<SessionInfo> getAllSessions(Collection<String> serverIds) { List<SessionInfo> sessions = new LinkedList<SessionInfo>(); for (String server : serverIds) { SessionQueryType queryType = queryFactory.getSessionQueryType(server); Collection<SessionInfo> queriedSessions = queryType.getAllSessions(); if (debug.messageEnabled()) { debug.message(MessageFormat.format( "SessionQueryManager#getAllSessions() :: Queried {0} from: {1}", queriedSessions.size(), server)); } sessions.addAll(queriedSessions); } return sessions; } }
SessionQueryManager { public Collection<SessionInfo> getAllSessions(Collection<String> serverIds) { List<SessionInfo> sessions = new LinkedList<SessionInfo>(); for (String server : serverIds) { SessionQueryType queryType = queryFactory.getSessionQueryType(server); Collection<SessionInfo> queriedSessions = queryType.getAllSessions(); if (debug.messageEnabled()) { debug.message(MessageFormat.format( "SessionQueryManager#getAllSessions() :: Queried {0} from: {1}", queriedSessions.size(), server)); } sessions.addAll(queriedSessions); } return sessions; } SessionQueryManager(SessionQueryFactory queryFactory); }
SessionQueryManager { public Collection<SessionInfo> getAllSessions(Collection<String> serverIds) { List<SessionInfo> sessions = new LinkedList<SessionInfo>(); for (String server : serverIds) { SessionQueryType queryType = queryFactory.getSessionQueryType(server); Collection<SessionInfo> queriedSessions = queryType.getAllSessions(); if (debug.messageEnabled()) { debug.message(MessageFormat.format( "SessionQueryManager#getAllSessions() :: Queried {0} from: {1}", queriedSessions.size(), server)); } sessions.addAll(queriedSessions); } return sessions; } SessionQueryManager(SessionQueryFactory queryFactory); Collection<SessionInfo> getAllSessions(Collection<String> serverIds); }
SessionQueryManager { public Collection<SessionInfo> getAllSessions(Collection<String> serverIds) { List<SessionInfo> sessions = new LinkedList<SessionInfo>(); for (String server : serverIds) { SessionQueryType queryType = queryFactory.getSessionQueryType(server); Collection<SessionInfo> queriedSessions = queryType.getAllSessions(); if (debug.messageEnabled()) { debug.message(MessageFormat.format( "SessionQueryManager#getAllSessions() :: Queried {0} from: {1}", queriedSessions.size(), server)); } sessions.addAll(queriedSessions); } return sessions; } SessionQueryManager(SessionQueryFactory queryFactory); Collection<SessionInfo> getAllSessions(Collection<String> serverIds);  }