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);
}
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);
}
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();
}
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());
}
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();
}
Aggregations