use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleCloudApiSelectorPanelTest method getSelectedLibraries_withOneFocused_returnsEmptySet.
@Test
public void getSelectedLibraries_withOneFocused_returnsEmptySet() {
CloudLibrary library1 = LIBRARY_1.toCloudLibrary();
CloudLibrary library2 = LIBRARY_2.toCloudLibrary();
GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library1, library2), testFixture.getProject());
JTable table = panel.getCloudLibrariesTable();
table.setRowSelectionInterval(0, 0);
assertThat(panel.getSelectedLibraries()).isEmpty();
}
use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleCloudApiSelectorPanelTest method getPanel_withOneLibrary_noSelection_hasCheckboxAndEmptyDetails.
@Test
public void getPanel_withOneLibrary_noSelection_hasCheckboxAndEmptyDetails() {
CloudLibrary library = LIBRARY_1.toCloudLibrary();
GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library), testFixture.getProject());
JTable table = panel.getCloudLibrariesTable();
assertThat(table.getSelectionModel().isSelectionEmpty()).isTrue();
TableModel model = table.getModel();
assertThat(model.getRowCount()).isEqualTo(1);
assertThat(model.getValueAt(0, 0)).isEqualTo(library);
assertThat((Boolean) model.getValueAt(0, 1)).isFalse();
assertDetailsEmpty(panel.getDetailsPanel());
}
use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleCloudApiSelectorPanelTest method getPanel_withBomAndNoDependencyVersion_displaysEmptyVersion.
@Test
public void getPanel_withBomAndNoDependencyVersion_displaysEmptyVersion() {
// TODO (eshaul): remove once feature is released
when(pluginInfoService.shouldEnable(GctFeature.BOM)).thenReturn(true);
when(mavenService.getManagedDependencyVersion(any(), anyString())).thenReturn(Optional.empty());
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("");
assertThat(panel.getDetailsPanel().getVersionLabel().getIcon()).isNull();
}
use of com.google.cloud.tools.libraries.json.CloudLibrary in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudLibraryProjectStateTest method getCloudLibraries_withCloudAndNonCloudDependencies_returnsValidCloudLibrary.
@Test
public void getCloudLibraries_withCloudAndNonCloudDependencies_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 cloudDependency = new MavenId(groupId, artifactId, "1.0");
MavenId nonCloudDependency = new MavenId("my-group", "my-artifact", "1.0");
writeDependenciesToPom(module, ImmutableList.of(cloudDependency, nonCloudDependency));
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 CloudLibraryProjectStateTest method assertThat_cloudLibrariesContainsExactlyOne.
private void assertThat_cloudLibrariesContainsExactlyOne(Set<CloudLibrary> cloudLibraries) {
assertThat(cloudLibraries.size()).isEqualTo(1);
CloudLibrary library = cloudLibraries.iterator().next();
assertThat(library.getName()).isEqualTo(LIBRARY.name());
}
Aggregations