/** * Returns either cached state (if we were previously watching this state in this or the last IDE * session) Or it returns a partially valid state, which will later be filled in by the {@link * CloudDebuggerRunner} * * @param executor the execution mode selected by the user (run, debug, profile etc.) * @param environment the environment object containing additional settings for executing the * configuration. */ @Nullable @Override public RunProfileState getState( @NotNull Executor executor, @NotNull ExecutionEnvironment environment) { if (processState == null) { return new CloudDebugProcessState( googleUsername, null /* debug id */, cloudProjectId, null /* project number */, getProject()); } return processState; }
@NotNull public CloudDebugProcessState buildResult(Project project) { CloudProject cloudProject = projectSelector.getSelectedProject(); String projectId = Optional.ofNullable(cloudProject).map(CloudProject::projectId).orElse(""); String projectNumberString = Optional.ofNullable(cloudProject) .map(CloudProject::projectNumber) .map(Object::toString) .orElse(null); DebugTarget selectedItem = (DebugTarget) targetSelector.getSelectedItem(); String savedDebuggeeId = selectedItem != null ? selectedItem.getId() : null; return new CloudDebugProcessState( credentialedUser != null ? credentialedUser.getEmail() : null, savedDebuggeeId, projectId, projectNumberString, project); }
private XDebugSession createDebugSettingsAndAddToRunnerSettings( List<RunnerAndConfigurationSettings> runnerSettings, boolean isStopped, boolean hasDebugSession, Boolean listenInBackground) { CloudDebugRunConfiguration runConfiguration = mock(CloudDebugRunConfiguration.class); if (listenInBackground != null) { CloudDebugProcessState processState = new CloudDebugProcessState(); processState.setListenInBackground(listenInBackground); when(runConfiguration.getProcessState()).thenReturn(processState); } RunnerAndConfigurationSettings configurationSettings = mock(RunnerAndConfigurationSettings.class); when(configurationSettings.getConfiguration()).thenReturn(runConfiguration); runnerSettings.add(configurationSettings); if (hasDebugSession) { return createMockSession(isStopped, runConfiguration); } else { return null; } }
@Before public void setUp() throws Exception { cloudDebugProcessState = new CloudDebugProcessState(); cloudDebugGlobalPoller = new CloudDebugGlobalPoller(); notificationsHandler = setupNotificationHandlerForVerification(); }
public void testSerialization() throws IOException { CloudDebugProcessState state = new CloudDebugProcessState("emailUser", "debuggeeId", "projectName", "projectNumber", null); Element element = XmlSerializer.serialize(state); state = XmlSerializer.deserialize(element, CloudDebugProcessState.class); assertNotNull(state); assertTrue("debuggeeId".equals(state.getDebuggeeId())); assertTrue("emailUser".equals(state.getUserEmail())); assertTrue("projectName".equals(state.getProjectName())); assertTrue("projectNumber".equals(state.getProjectNumber())); }
@Test public void testListensInBackground_returnsFalseIfStateDoesNotListenInBackground() throws Exception { CloudDebugProcessState state = new CloudDebugProcessState(); state.setListenInBackground(false); assertFalse(new CloudDebugProcessStateCollector().listensInBackground(state)); }
new CloudDebugProcessState(); // Mockito.mock(CloudDebugProcessState.class); state.setUserEmail("mockUser@foo.com");
@Test public void testListensInBackground_returnsTrueIfStateListensInBackground() throws Exception { CloudDebugProcessState state = new CloudDebugProcessState(); state.setListenInBackground(true); assertTrue(new CloudDebugProcessStateCollector().listensInBackground(state)); }
/** * After selecting a module that requires sync/stash, any subsequent module that is selected that * has no remote repository is shown the sync/stash checkbox regardless of its state. The * visibility of this option needs to be properly reset. */ public void testSyncStashReset() { mockLoggedInUser(); binding = mock(ProjectDebuggeeBinding.class); when(binding.buildResult(any(Project.class))).thenReturn(new CloudDebugProcessState()); // Step 1 - select a debuggable module that requires stashing // The stash checkbox should be visible to the user boolean needsStash = true; boolean hasRemoteRepository = true; ProjectRepositoryValidator repositoryValidator = mock(ProjectRepositoryValidator.class); SyncResult syncResult = mockSyncResult(needsStash, hasRemoteRepository); when(repositoryValidator.checkSyncStashState()).thenReturn(syncResult); CloudAttachDialog dialog = initDialog(); dialog.setProjectRepositoryValidator(repositoryValidator); selectProjectWithDebuggableModules(); assertTrue(syncStashCheckbox.isVisible()); // Step 2 - select a project with no remote repo that does NOT require stashing // The stash checkbox should now be hidden from the user needsStash = false; hasRemoteRepository = false; syncResult = mockSyncResult(needsStash, hasRemoteRepository); when(repositoryValidator.checkSyncStashState()).thenReturn(syncResult); selectEmptyProject(); assertFalse(syncStashCheckbox.isVisible()); dialog.close(0); }
public void testDebuggableModuleSelected() { mockLoggedInUser(); binding = mock(ProjectDebuggeeBinding.class); when(binding.buildResult(any(Project.class))).thenReturn(new CloudDebugProcessState()); ProjectRepositoryValidator repositoryValidator = mock(ProjectRepositoryValidator.class); SyncResult syncResult = mockSyncResult(false, true); when(repositoryValidator.checkSyncStashState()).thenReturn(syncResult); CloudAttachDialog dialog = initDialog(); dialog.setProjectRepositoryValidator(repositoryValidator); selectProjectWithDebuggableModules(); ValidationInfo error = dialog.doValidate(); assertNull(error); assertFalse(warningMessage.isVisible()); assertFalse(warningHeader.isVisible()); assertFalse(syncStashCheckbox.isVisible()); assertTrue(targetSelector.isEnabled()); dialog.close(0); }
new CloudDebugProcessState(USER, DEBUGEE_ID, PROJECT_NAME, PROJECT_NUMBER, null); assertEquals(USER, state.getUserEmail());
new CloudDebugProcessState(USER, DEBUGEE_ID, PROJECT_NAME, PROJECT_NUMBER, null); assertEquals(USER, state.getUserEmail());