use of com.google.cloud.tools.intellij.debugger.CloudDebugProcessState in project google-cloud-intellij by GoogleCloudPlatform.
the class ProjectDebuggeeBinding method buildResult.
@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);
}
use of com.google.cloud.tools.intellij.debugger.CloudDebugProcessState in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudAttachDialogTest method testDebuggableModuleSelected.
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);
}
use of com.google.cloud.tools.intellij.debugger.CloudDebugProcessState in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudAttachDialogTest method testSyncStashReset.
/**
* 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);
}
Aggregations