use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudLibraryProjectStateTest method getCloudLibraries_withOnlyCloudDependencies_returnsValidCloudLibrary.
@Test
public void getCloudLibraries_withOnlyCloudDependencies_returnsValidCloudLibrary() {
when(librariesService.getCloudLibraries()).thenReturn(ImmutableList.of(LIBRARY.toCloudLibrary()));
ApplicationManager.getApplication().invokeAndWait(() -> {
try {
Module module = MavenTestUtils.getInstance().createNewMavenModule(moduleBuilder, testFixture.getProject());
TestCloudLibraryClientMavenCoordinates mavenCoordinates = LIBRARY.clients().get(0).mavenCoordinates();
String groupId = mavenCoordinates.groupId();
String artifactId = mavenCoordinates.artifactId();
MavenId managedDependency = new MavenId(groupId, artifactId, "1.0");
writeDependenciesToPom(module, ImmutableList.of(managedDependency));
state.syncManagedProjectLibraries();
Set<CloudLibrary> libraries = state.getCloudLibraries(module);
assertThat_cloudLibrariesContainsExactlyOne(libraries);
} finally {
MavenServerManager.getInstance().shutdown(true);
}
});
}
use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleCloudApiSelectorPanelTest method getApisToEnable_withAllLibrariesChecked_AndNoShouldEnableChecked_returnsNoneEnabled.
@Test
public void getApisToEnable_withAllLibrariesChecked_AndNoShouldEnableChecked_returnsNoneEnabled() {
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(), false);
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_withMultipleLibraries_multipleSelected_hasCheckboxesAndPopulatedDetails.
@Test
public void getPanel_withMultipleLibraries_multipleSelected_hasCheckboxesAndPopulatedDetails() {
CloudLibrary library1 = LIBRARY_1.toCloudLibrary();
CloudLibrary library2 = LIBRARY_2.toCloudLibrary();
// The given list should be reordered by the name's natural order, placing library1 first.
GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library2, library1), testFixture.getProject());
JTable table = panel.getCloudLibrariesTable();
checkAddLibraryCheckbox(table, 1);
checkAddLibraryCheckbox(table, 0);
assertThat(table.getSelectionModel().isSelectedIndex(0)).isTrue();
assertThat(table.getSelectionModel().isSelectedIndex(1)).isFalse();
TableModel model = table.getModel();
assertThat(model.getRowCount()).isEqualTo(2);
assertThat(model.getValueAt(0, 0)).isEqualTo(library1);
assertThat(model.getValueAt(1, 0)).isEqualTo(library2);
assertThat((Boolean) model.getValueAt(0, 1)).isTrue();
assertThat((Boolean) model.getValueAt(1, 1)).isTrue();
assertDetailsShownForLibrary(panel.getDetailsPanel(), LIBRARY_1, JAVA_CLIENT_1);
}
use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleCloudApiSelectorPanelTest method getPanel_withOneLibrary_selectedLibrary_hasCheckboxAndPopulatedDetails.
@Test
public void getPanel_withOneLibrary_selectedLibrary_hasCheckboxAndPopulatedDetails() {
CloudLibrary library = LIBRARY_1.toCloudLibrary();
GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library), testFixture.getProject());
JTable table = panel.getCloudLibrariesTable();
checkAddLibraryCheckbox(table, 0);
assertThat(table.getSelectionModel().isSelectedIndex(0)).isTrue();
TableModel model = table.getModel();
assertThat(model.getRowCount()).isEqualTo(1);
assertThat(model.getValueAt(0, 0)).isEqualTo(library);
assertThat((Boolean) model.getValueAt(0, 1)).isTrue();
assertDetailsShownForLibrary(panel.getDetailsPanel(), LIBRARY_1, JAVA_CLIENT_1);
}
use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleCloudApiSelectorPanelTest method getPanel_withMultipleLibraries_selectedLibrary_hasCheckboxesAndPopulatedDetails.
@Test
public void getPanel_withMultipleLibraries_selectedLibrary_hasCheckboxesAndPopulatedDetails() {
CloudLibrary library1 = LIBRARY_1.toCloudLibrary();
CloudLibrary library2 = LIBRARY_2.toCloudLibrary();
// The given list should be reordered by the name's natural order, placing library1 first.
GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library2, library1), testFixture.getProject());
JTable table = panel.getCloudLibrariesTable();
// Checks the second row's checkbox, which should be library2.
checkAddLibraryCheckbox(table, 1);
assertThat(table.getSelectionModel().isSelectedIndex(0)).isFalse();
assertThat(table.getSelectionModel().isSelectedIndex(1)).isTrue();
TableModel model = table.getModel();
assertThat(model.getRowCount()).isEqualTo(2);
assertThat(model.getValueAt(0, 0)).isEqualTo(library1);
assertThat(model.getValueAt(1, 0)).isEqualTo(library2);
assertThat((Boolean) model.getValueAt(0, 1)).isFalse();
assertThat((Boolean) model.getValueAt(1, 1)).isTrue();
assertDetailsShownForLibrary(panel.getDetailsPanel(), LIBRARY_2, JAVA_CLIENT_2);
}
Aggregations