Search in sources :

Example 11 with CloudProject

use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.

the class GcsBucketPanelTest method testNotificationLabel_nonExistentProject.

@Test
public void testNotificationLabel_nonExistentProject() {
    CloudProject nonExistingProject = CloudProject.create("non-existent-project", "non-existent-project", "non-existing-user");
    when(projectSelector.getSelectedProject()).thenReturn(nonExistingProject);
    bucketPanel.refresh();
    assertTrue(bucketPanel.getNotificationPanel().isVisible());
    assertFalse(bucketPanel.getBucketListPanel().isVisible());
    assertThat(bucketPanel.getNotificationLabel().getText()).isEqualTo("Could not load buckets for selected project.");
}
Also used : CloudProject(com.google.cloud.tools.intellij.project.CloudProject) Test(org.junit.Test)

Example 12 with CloudProject

use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineFlexibleDeploymentEditorTest method applyEditorTo_withUser_doesSetGoogleUsername.

@Test
public void applyEditorTo_withUser_doesSetGoogleUsername() {
    when(credentialedUser.getEmail()).thenReturn(EMAIL);
    CloudProject project = CloudProject.create("some-project", "some-project", EMAIL);
    when(projectSelector.getSelectedProject()).thenReturn(project);
    editor.applyEditorTo(configuration);
    assertThat(configuration.getGoogleUsername()).isEqualTo(EMAIL);
}
Also used : CloudProject(com.google.cloud.tools.intellij.project.CloudProject) Test(org.junit.Test)

Example 13 with CloudProject

use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfigurationPanel method applyEditorTo.

/**
 * Shared implementation of {@link
 * com.intellij.openapi.options.SettingsEditor#applyEditorTo(Object)}. To be invoked by users of
 * this panel in the overriden method.
 */
public void applyEditorTo(@NotNull AppEngineDeploymentConfiguration configuration) {
    configuration.setVersion(versionIdField.getText());
    configuration.setPromote(promoteCheckbox.isSelected());
    configuration.setStopPreviousVersion(stopPreviousVersionCheckbox.isSelected());
    configuration.setDeployAllConfigs(deployAllConfigsCheckbox.isSelected());
    CloudProject selectedProject = projectSelector.getSelectedProject();
    if (selectedProject != null) {
        configuration.setCloudProjectName(selectedProject.projectId());
        configuration.setGoogleUsername(selectedProject.googleUsername());
    }
}
Also used : CloudProject(com.google.cloud.tools.intellij.project.CloudProject)

Example 14 with CloudProject

use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfigurationPanel method resetEditorFrom.

/**
 * Shared implementation of {@link
 * com.intellij.openapi.options.SettingsEditor#resetEditorFrom(Object)}. To be invoked by users of
 * this panel in the overriden method.
 */
public void resetEditorFrom(@NotNull AppEngineDeploymentConfiguration configuration) {
    promoteCheckbox.setSelected(configuration.isPromote());
    versionIdField.setText(configuration.getVersion());
    stopPreviousVersionCheckbox.setSelected(configuration.isStopPreviousVersion());
    deployAllConfigsCheckbox.setSelected(configuration.isDeployAllConfigs());
    if (configuration.getEnvironment() != null) {
        environmentLabel.setText(configuration.getEnvironment().localizedLabel());
    }
    // TODO(ivanporty) add project name to configuration and then use separate project ID field.
    if (configuration.getCloudProjectName() != null && configuration.getGoogleUsername() != null) {
        CloudProject cloudProject = CloudProject.create(configuration.getCloudProjectName(), configuration.getCloudProjectName(), configuration.getGoogleUsername());
        projectSelector.setSelectedProject(cloudProject);
    } else {
        // unset project, load default active cloud project (if available for this IDE project)
        projectSelector.loadActiveCloudProject();
    }
    refreshApplicationInfoPanel(projectSelector.getSelectedProject());
}
Also used : CloudProject(com.google.cloud.tools.intellij.project.CloudProject)

Example 15 with CloudProject

use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.

the class SetupCloudRepositoryDialog method updateButtons.

private void updateButtons() {
    CloudProject selectedProject = projectSelector.getSelectedProject();
    Optional<CredentialedUser> user = Services.getLoginService().getLoggedInUser(selectedProject.googleUsername());
    if (!StringUtil.isEmpty(selectedProject.projectId()) && !user.isPresent()) {
        setErrorText(GctBundle.message("cloud.repository.dialog.invalid.project"));
        setOKActionEnabled(false);
        return;
    }
    if (!StringUtil.isEmpty(repositorySelector.getText()) && StringUtil.isEmpty(repositorySelector.getSelectedRepository())) {
        setErrorText(GctBundle.message("cloud.repository.dialog.invalid.repository"));
        setOKActionEnabled(false);
        return;
    }
    if (!user.isPresent() || StringUtil.isEmpty(repositorySelector.getSelectedRepository())) {
        setErrorText(null);
        setOKActionEnabled(false);
        return;
    }
    if (StringUtil.isEmpty(remoteNameSelector.getText())) {
        setErrorText(GctBundle.message("uploadtogcp.dialog.missing.remote"));
        setOKActionEnabled(false);
        return;
    }
    setErrorText(null);
    setOKActionEnabled(true);
}
Also used : CloudProject(com.google.cloud.tools.intellij.project.CloudProject) CredentialedUser(com.google.cloud.tools.intellij.login.CredentialedUser)

Aggregations

CloudProject (com.google.cloud.tools.intellij.project.CloudProject)20 Test (org.junit.Test)10 CredentialedUser (com.google.cloud.tools.intellij.login.CredentialedUser)5 CloudLibrary (com.google.cloud.tools.libraries.json.CloudLibrary)3 Role (com.google.api.services.iam.v1.model.Role)2 Nullable (org.jetbrains.annotations.Nullable)2 Base64 (com.google.api.client.util.Base64)1 CloudResourceManager (com.google.api.services.cloudresourcemanager.CloudResourceManager)1 Binding (com.google.api.services.cloudresourcemanager.model.Binding)1 GetIamPolicyRequest (com.google.api.services.cloudresourcemanager.model.GetIamPolicyRequest)1 Policy (com.google.api.services.cloudresourcemanager.model.Policy)1 SetIamPolicyRequest (com.google.api.services.cloudresourcemanager.model.SetIamPolicyRequest)1 Iam (com.google.api.services.iam.v1.Iam)1 CreateServiceAccountKeyRequest (com.google.api.services.iam.v1.model.CreateServiceAccountKeyRequest)1 CreateServiceAccountRequest (com.google.api.services.iam.v1.model.CreateServiceAccountRequest)1 ServiceAccount (com.google.api.services.iam.v1.model.ServiceAccount)1 ServiceAccountKey (com.google.api.services.iam.v1.model.ServiceAccountKey)1 ServiceManagement (com.google.api.services.servicemanagement.ServiceManagement)1 EnableServiceRequest (com.google.api.services.servicemanagement.model.EnableServiceRequest)1 GoogleCloudCoreIcons (com.google.cloud.tools.intellij.GoogleCloudCoreIcons)1