Search in sources :

Example 11 with CloudLibrary

use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleCloudApiSelectorPanelTest method getPanel_withVersionReturnedFromBomQuery_displaysVersionFromBom.

@Test
public void getPanel_withVersionReturnedFromBomQuery_displaysVersionFromBom() {
    // TODO (eshaul): remove once feature is released
    when(pluginInfoService.shouldEnable(GctFeature.BOM)).thenReturn(true);
    String libVersion = "9.9-alpha";
    when(mavenService.getManagedDependencyVersion(any(), anyString())).thenReturn(Optional.of(libVersion));
    CloudLibrary cloudLibrary = LIBRARY_1.toCloudLibrary();
    GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(cloudLibrary), testFixture.getProject());
    panel.getDetailsPanel().setCloudLibrary(cloudLibrary, BOM_VERSION, panel.getApiManagementMap().get(cloudLibrary));
    assertThat(panel.getDetailsPanel().getVersionLabel().getText()).isEqualTo("Version: " + libVersion);
}
Also used : TestCloudLibrary(com.google.cloud.tools.intellij.testing.apis.TestCloudLibrary) CloudLibrary(com.google.cloud.tools.libraries.json.CloudLibrary) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 12 with CloudLibrary

use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleCloudApiSelectorPanelTest method getApisToEnable_withAllLibrariesChecked_AndSomeShouldEnableChecked_returnsSomeEnabled.

@Test
public void getApisToEnable_withAllLibrariesChecked_AndSomeShouldEnableChecked_returnsSomeEnabled() {
    CloudLibrary library1 = LIBRARY_1.toCloudLibrary();
    CloudLibrary library2 = LIBRARY_2.toCloudLibrary();
    GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library1, library2), testFixture.getProject());
    JTable table = panel.getCloudLibrariesTable();
    checkAddLibraryCheckbox(table, 0);
    checkAddLibraryCheckbox(table, 1);
    Map<CloudLibrary, CloudApiManagementSpec> apiManagementMap = panel.getApiManagementMap();
    panel.getDetailsPanel().setCloudLibrary(library1, BOM_VERSION, apiManagementMap.get(library1));
    checkEnableCheckbox(panel.getDetailsPanel().getEnableApiCheckbox(), false);
    panel.getDetailsPanel().setCloudLibrary(library2, BOM_VERSION, apiManagementMap.get(library2));
    checkEnableCheckbox(panel.getDetailsPanel().getEnableApiCheckbox(), true);
    assertThat(panel.getApisToEnable()).containsExactly(library2);
}
Also used : JTable(javax.swing.JTable) TestCloudLibrary(com.google.cloud.tools.intellij.testing.apis.TestCloudLibrary) CloudLibrary(com.google.cloud.tools.libraries.json.CloudLibrary) Test(org.junit.Test)

Example 13 with CloudLibrary

use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleCloudApiSelectorPanelTest method getApisToEnable_withNoLibrariesChecked_AndAllShouldEnableChecked_returnsNoneEnabled.

@Test
public void getApisToEnable_withNoLibrariesChecked_AndAllShouldEnableChecked_returnsNoneEnabled() {
    CloudLibrary library1 = LIBRARY_1.toCloudLibrary();
    CloudLibrary library2 = LIBRARY_2.toCloudLibrary();
    GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library1, library2), testFixture.getProject());
    Map<CloudLibrary, CloudApiManagementSpec> apiManagementMap = panel.getApiManagementMap();
    panel.getDetailsPanel().setCloudLibrary(library1, BOM_VERSION, apiManagementMap.get(library1));
    checkEnableCheckbox(panel.getDetailsPanel().getEnableApiCheckbox(), true);
    panel.getDetailsPanel().setCloudLibrary(library2, BOM_VERSION, apiManagementMap.get(library2));
    checkEnableCheckbox(panel.getDetailsPanel().getEnableApiCheckbox(), true);
    assertThat(panel.getApisToEnable()).isEmpty();
}
Also used : TestCloudLibrary(com.google.cloud.tools.intellij.testing.apis.TestCloudLibrary) CloudLibrary(com.google.cloud.tools.libraries.json.CloudLibrary) Test(org.junit.Test)

Example 14 with CloudLibrary

use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleCloudApiSelectorPanelTest method getPanel_withNoVersionReturnedFromBomQuery_fallsBackToAndDisplaysStaticVersion.

@Test
public void getPanel_withNoVersionReturnedFromBomQuery_fallsBackToAndDisplaysStaticVersion() {
    // TODO (eshaul): remove once feature is released
    when(pluginInfoService.shouldEnable(GctFeature.BOM)).thenReturn(true);
    CloudLibrary cloudLibrary = LIBRARY_1.toCloudLibrary();
    GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(cloudLibrary), testFixture.getProject());
    panel.getDetailsPanel().setCloudLibrary(cloudLibrary, null, /*bomVersion*/
    panel.getApiManagementMap().get(cloudLibrary));
    assertThat(panel.getDetailsPanel().getVersionLabel().getText()).isEqualTo("Version: " + JAVA_CLIENT_MAVEN_COORDS_1.version());
}
Also used : TestCloudLibrary(com.google.cloud.tools.intellij.testing.apis.TestCloudLibrary) CloudLibrary(com.google.cloud.tools.libraries.json.CloudLibrary) Test(org.junit.Test)

Example 15 with CloudLibrary

use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleCloudApiSelectorPanelTest method getManagementUI_withLibraryAndProjectSelected_isEnabled.

@Test
public void getManagementUI_withLibraryAndProjectSelected_isEnabled() {
    CloudLibrary library = LIBRARY_1.toCloudLibrary();
    GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library), testFixture.getProject());
    JTable table = panel.getCloudLibrariesTable();
    checkAddLibraryCheckbox(table, 0);
    panel.getDetailsPanel().setCloudLibrary(library, BOM_VERSION, panel.getApiManagementMap().get(library));
    CloudProject cloudProject = CloudProject.create("name", "id", "user");
    ProjectSelector projectSelector = panel.getProjectSelector();
    projectSelector.setSelectedProject(cloudProject);
    projectSelector.getProjectSelectionListeners().forEach(listener -> listener.projectSelected(cloudProject));
    assertThat(panel.getDetailsPanel().getEnableApiCheckbox().isEnabled()).isTrue();
    assertThat(panel.getDetailsPanel().getManagementInfoPanel().isVisible()).isFalse();
}
Also used : CloudProject(com.google.cloud.tools.intellij.project.CloudProject) JTable(javax.swing.JTable) TestCloudLibrary(com.google.cloud.tools.intellij.testing.apis.TestCloudLibrary) CloudLibrary(com.google.cloud.tools.libraries.json.CloudLibrary) ProjectSelector(com.google.cloud.tools.intellij.project.ProjectSelector) Test(org.junit.Test)

Aggregations

CloudLibrary (com.google.cloud.tools.libraries.json.CloudLibrary)29 TestCloudLibrary (com.google.cloud.tools.intellij.testing.apis.TestCloudLibrary)25 Test (org.junit.Test)24 JTable (javax.swing.JTable)13 TableModel (javax.swing.table.TableModel)7 Role (com.google.api.services.iam.v1.model.Role)3 Module (com.intellij.openapi.module.Module)3 MavenId (org.jetbrains.idea.maven.model.MavenId)3 CloudProject (com.google.cloud.tools.intellij.project.CloudProject)2 TestCloudLibraryClientMavenCoordinates (com.google.cloud.tools.intellij.testing.apis.TestCloudLibrary.TestCloudLibraryClientMavenCoordinates)2 GoogleCloudCoreIcons (com.google.cloud.tools.intellij.GoogleCloudCoreIcons)1 GctTracking (com.google.cloud.tools.intellij.analytics.GctTracking)1 UsageTrackerProvider (com.google.cloud.tools.intellij.analytics.UsageTrackerProvider)1 PropertiesFileFlagReader (com.google.cloud.tools.intellij.flags.PropertiesFileFlagReader)1 CredentialedUser (com.google.cloud.tools.intellij.login.CredentialedUser)1 ProjectSelector (com.google.cloud.tools.intellij.project.ProjectSelector)1 GctBundle (com.google.cloud.tools.intellij.util.GctBundle)1 Notification (com.intellij.notification.Notification)1 NotificationDisplayType (com.intellij.notification.NotificationDisplayType)1 NotificationGroup (com.intellij.notification.NotificationGroup)1