use of org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization in project sonarlint-core by SonarSource.
the class WsHelperImplTest method testListOrganizations.
@Test
public void testListOrganizations() {
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?ps=500&p=1", "/orgs/orgsp1.pb");
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?ps=500&p=2", "/orgs/orgsp2.pb");
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?ps=500&p=3", "/orgs/orgsp3.pb");
List<RemoteOrganization> orgs = WsHelperImpl.listOrganizations(client, serverChecker, new ProgressWrapper(null));
assertThat(orgs).hasSize(4);
verify(serverChecker).checkVersionAndStatus("6.3");
when(serverChecker.checkVersionAndStatus("6.3")).thenThrow(UnsupportedServerException.class);
try {
WsHelperImpl.listOrganizations(client, serverChecker, new ProgressWrapper(null));
fail("Expected exception");
} catch (UnsupportedServerException e) {
// Success
}
}
use of org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization in project sonarlint-core by SonarSource.
the class DefaultRemoteOrganizationTest method testRoundTrip.
@Test
public void testRoundTrip() {
Organization org = Organization.newBuilder().setName("name").setKey("key").setDescription("desc").build();
RemoteOrganization remoteOrg = new DefaultRemoteOrganization(org);
assertThat(remoteOrg.getKey()).isEqualTo("key");
assertThat(remoteOrg.getName()).isEqualTo("name");
assertThat(remoteOrg.getDescription()).isEqualTo("desc");
}
use of org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization in project sonarlint-core by SonarSource.
the class OrganizationTest method downloadOrganizations.
@Test
public void downloadOrganizations() throws Exception {
WsHelper helper = new WsHelperImpl();
List<RemoteOrganization> organizations = helper.listOrganizations(getServerConfigForOrg(null), null);
assertThat(organizations).hasSize(2);
}
use of org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization in project sonarlint-intellij by SonarSource.
the class OrganizationStep method createUIComponents.
private void createUIComponents() {
JBList list = new JBList();
list.setLayoutOrientation(VERTICAL);
list.setVisibleRowCount(8);
list.setEnabled(true);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setCellRenderer(new ListRenderer());
Convertor<Object, String> convertor = o -> {
RemoteOrganization org = (RemoteOrganization) o;
return org.getName() + " " + org.getKey();
};
new ListSpeedSearch(list, convertor);
this.orgList = list;
}
use of org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization in project sonarlint-intellij by SonarSource.
the class OrganizationStep method _init.
@Override
public void _init() {
List<RemoteOrganization> list = model.getOrganizationList();
int size = list.size();
orgList.setListData(list.toArray(new RemoteOrganization[size]));
orgList.addListSelectionListener(e -> fireStateChanged());
if (model.getOrganization() != null) {
for (int i = 0; i < orgList.getModel().getSize(); i++) {
RemoteOrganization org = (RemoteOrganization) orgList.getModel().getElementAt(i);
if (model.getOrganization().equals(org.getKey())) {
orgList.setSelectedIndex(i);
orgList.ensureIndexIsVisible(i);
break;
}
}
}
}
Aggregations