/** * Called from {@link CloudDebugRunConfiguration}, it finds any serialized state for that named * run config and if the project name matches, it initializes and returns it. * * @param runConfig the runconfig for which state is queried for * @param projectName the GCP project name associated with this runconfig * @return deserialized state that may have been cached in workspace.xml */ public CloudDebugProcessState getState(@NotNull String runConfig, @NotNull String projectName) { CloudDebugProcessState state = stateMap.get(runConfig); if (state != null && state.getProjectName() != null && state.getProjectName().equals(projectName)) { state.setProject(project); return state; } return null; }
/** * CloudDebugProcessState can be initialized with partial state to indicate preferences on the * {@link CloudDebugRunConfiguration}. When the process state is partial, the attach dialog is * used to make it complete. isValidDebuggee must be true for the attach to continue. * * @param userEmail the user's email which corresponds to a login {@link CredentialedUser} * @param debuggeeId a String Id that represents a target application to debug (debuggee) * @param projectName a alpha-numeric String name identifying a GCP project that owns the target * debuggee * @param projectNumber a numeric String identifying the same GCP project that owns the target * debuggee * @param project the intelliJ IDE project */ public CloudDebugProcessState( @Nullable String userEmail, @Nullable String debuggeeId, @Nullable String projectName, @Nullable String projectNumber, @Nullable Project project) { setUserEmail(userEmail); setDebuggeeId(debuggeeId); setProjectName(projectName); setProjectNumber(projectNumber); setProject(project); setListenInBackground(false); }
@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(); }