@Test public void testNotRunningConfiguration_returnsFalseIfConfigIsInRunningConfigurations() { RunConfiguration config = mock(RunConfiguration.class); HashSet<RunProfile> runningConfigurations = new HashSet<RunProfile>(); runningConfigurations.add(config); assertFalse( new CloudDebugProcessStateCollector() .notRunningConfiguration(runningConfigurations, config)); }
@Test public void testNotRunningConfiguration_returnsTrueIfThereAreNoRunningConfigurations() { RunConfiguration config = mock(RunConfiguration.class); assertTrue( new CloudDebugProcessStateCollector() .notRunningConfiguration(new HashSet<RunProfile>(), config)); }
@Test public void testNotRunningConfiguration_returnsFalseIfNullConfigIsPassedIn() { assertFalse( new CloudDebugProcessStateCollector() .notRunningConfiguration(new HashSet<RunProfile>(), null)); }
@Test public void testNotStoppedAndHasRunProfile_returnsFalseIfStoppedAndHasProfile() { XDebugSession session = createMockSession(true, mock(RunProfile.class)); assertFalse(new CloudDebugProcessStateCollector().notStoppedAndHasRunProfile(session)); }
@Test public void testNotStoppedAndHasRunProfile_returnsTrueIfNotStoppedAndHasProfile() { XDebugSession session = createMockSession(false, mock(RunProfile.class)); assertTrue(new CloudDebugProcessStateCollector().notStoppedAndHasRunProfile(session)); }
@Test public void testListensInBackground_returnsFalseIfNullIsPassedIn() throws Exception { assertFalse(new CloudDebugProcessStateCollector().listensInBackground(null)); }
@Test public void testGetProfilesWithActiveDebugSession_returnsEmptySetIfNoDebugSessions() { Project project = mock(Project.class); createMockXDebuggerManager(project, new XDebugSession[0]); Set<RunProfile> profiles = new CloudDebugProcessStateCollector().getProfilesWithActiveDebugSession(project); assertNotNull(profiles); assertThat(profiles).hasSize(0); }
@Test public void testGetBackgroundListeningStates_returnsEmptyListWhenNoProjectIsOpen() { createMockProjectManagerWithProjects(new Project[0]); List<CloudDebugProcessState> backgroundListeningStates = new CloudDebugProcessStateCollector().getBackgroundListeningStates(); assertNotNull(backgroundListeningStates); assertThat(backgroundListeningStates).hasSize(0); }
@Test public void testGetProfilesWithActiveDebugSession_returnsNotStoppedSessionsWithRunProfile() { Project project = mock(Project.class); XDebugSession notStoppedSession = createMockSession(false, mock(CloudDebugRunConfiguration.class)); XDebugSession stoppedSession = createMockSession(true, mock(CloudDebugRunConfiguration.class)); XDebugSession stoppedSessionWithoutRunProfile = createMockSession(true, null); createMockXDebuggerManager( project, new XDebugSession[] {notStoppedSession, stoppedSession, stoppedSessionWithoutRunProfile}); Set<RunProfile> profiles = new CloudDebugProcessStateCollector().getProfilesWithActiveDebugSession(project); assertNotNull(profiles); assertThat(profiles).hasSize(1); }
@Test public void testNotStoppedAndHasRunProfile_returnsFalseIfStoppedAndHasNoProfile() { XDebugSession session = createMockSession(true, null); assertFalse(new CloudDebugProcessStateCollector().notStoppedAndHasRunProfile(session)); }
@Test public void testNotStoppedAndHasRunProfile_returnsFalseIfNotStoppedAndHasNoProfile() { XDebugSession session = createMockSession(false, null); assertFalse(new CloudDebugProcessStateCollector().notStoppedAndHasRunProfile(session)); }
@Test public void testListensInBackground_returnsFalseIfStateDoesNotListenInBackground() throws Exception { CloudDebugProcessState state = new CloudDebugProcessState(); state.setListenInBackground(false); assertFalse(new CloudDebugProcessStateCollector().listensInBackground(state)); }
@Test public void testListensInBackground_returnsTrueIfStateListensInBackground() throws Exception { CloudDebugProcessState state = new CloudDebugProcessState(); state.setListenInBackground(true); assertTrue(new CloudDebugProcessStateCollector().listensInBackground(state)); }
@Test public void testGetBackgroundListeningStates_withMultipleProjects() { int runningSessions = 1; int listeningSessions = 2; int notListeningSessions = 3; Project project1 = createProject(runningSessions, listeningSessions, notListeningSessions); Project project2 = createProject(runningSessions, listeningSessions, notListeningSessions); createMockProjectManagerWithProjects(new Project[] {project1, project2}); List<CloudDebugProcessState> backgroundListeningStates = new CloudDebugProcessStateCollector().getBackgroundListeningStates(); assertNotNull(backgroundListeningStates); assertThat(backgroundListeningStates).hasSize(2 * listeningSessions); for (CloudDebugProcessState state : backgroundListeningStates) { assertTrue(state.isListenInBackground()); } }