@Test public void testPollForChanges_firesNotificationOnIOException() throws IOException { cloudDebugProcessState.setListenInBackground(true); cloudDebugProcessState.setUserEmail(FAKE_USER_EMAIL); cloudDebugProcessState.setDebuggeeId(FAKE_DEBUGGEE_ID); cloudDebugProcessState.setProject(getProject()); setupCloudDebuggerBackendMockWithException(FAKE_USER_EMAIL, new IOException()); cloudDebugGlobalPoller.pollForChanges(cloudDebugProcessState); assertFalse(cloudDebugProcessState.isListenInBackground()); verifyNotificationFired(); }
@Test public void testPollForChanges_firesNotificationIfNoDebugClientObtained() { cloudDebugProcessState.setListenInBackground(true); cloudDebugProcessState.setProject(getProject()); cloudDebugGlobalPoller.pollForChanges(cloudDebugProcessState); assertFalse(cloudDebugProcessState.isListenInBackground()); verifyNotificationFired(); }
@NotNull private Notifications setupNotificationHandlerForVerification() { Notifications handler = mock(Notifications.class); // sending out notificationsHandler relies on several static method calls in // com.intellij.notification.Notifications, let's subscribe to them and do verification this way Application application = ApplicationManager.getApplication(); getProject().getMessageBus().connect(application).subscribe(Notifications.TOPIC, handler); return handler; }
@Before public void setUp() throws Exception { cloudDebugProcessState = new CloudDebugProcessState(); cloudDebugGlobalPoller = new CloudDebugGlobalPoller(); notificationsHandler = setupNotificationHandlerForVerification(); }