@Test public void shouldReturnAllSessionsReturnedByQueryTypes() { String badger = "Badger"; String weasel = "Weasel"; SessionInfo one = mock(SessionInfo.class); SessionInfo two = mock(SessionInfo.class); SessionQueryType typeOne = mock(SessionQueryType.class); given(typeOne.getAllSessions()).willReturn(Arrays.asList(new SessionInfo[]{one})); SessionQueryType typeTwo = mock(SessionQueryType.class); given(typeTwo.getAllSessions()).willReturn(Arrays.asList(new SessionInfo[]{two})); SessionQueryFactory mockFactory = mock(SessionQueryFactory.class); given(mockFactory.getSessionQueryType(badger)).willReturn(typeOne); given(mockFactory.getSessionQueryType(weasel)).willReturn(typeTwo); SessionQueryManager manager = new SessionQueryManager(mockFactory); Collection<SessionInfo> sessions = manager.getAllSessions(Arrays.asList(new String[]{badger, weasel})); assertEquals(2, sessions.size()); assertTrue(sessions.contains(one)); assertTrue(sessions.contains(two)); }
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);  }