Search in sources :

Example 1 with RemoteOrganization

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
    }
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) RemoteOrganization(org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization) UnsupportedServerException(org.sonarsource.sonarlint.core.client.api.exceptions.UnsupportedServerException) Test(org.junit.Test)

Example 2 with RemoteOrganization

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");
}
Also used : Organization(org.sonarqube.ws.Organizations.Organization) RemoteOrganization(org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization) RemoteOrganization(org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization) Test(org.junit.Test)

Example 3 with RemoteOrganization

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);
}
Also used : WsHelperImpl(org.sonarsource.sonarlint.core.WsHelperImpl) RemoteOrganization(org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization) WsHelper(org.sonarsource.sonarlint.core.client.api.connected.WsHelper) Test(org.junit.Test)

Example 4 with RemoteOrganization

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;
}
Also used : JComponent(javax.swing.JComponent) ListSelectionModel(javax.swing.ListSelectionModel) JBList(com.intellij.ui.components.JBList) RemoteOrganization(org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization) CommitStepException(com.intellij.ide.wizard.CommitStepException) VERTICAL(javax.swing.JList.VERTICAL) Convertor(com.intellij.util.containers.Convertor) JList(javax.swing.JList) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) AbstractWizardStepEx(com.intellij.ide.wizard.AbstractWizardStepEx) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) NotNull(org.jetbrains.annotations.NotNull) JPanel(javax.swing.JPanel) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) RemoteOrganization(org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization) JBList(com.intellij.ui.components.JBList)

Example 5 with RemoteOrganization

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;
            }
        }
    }
}
Also used : RemoteOrganization(org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization)

Aggregations

RemoteOrganization (org.sonarsource.sonarlint.core.client.api.connected.RemoteOrganization)5 Test (org.junit.Test)3 AbstractWizardStepEx (com.intellij.ide.wizard.AbstractWizardStepEx)1 CommitStepException (com.intellij.ide.wizard.CommitStepException)1 ColoredListCellRenderer (com.intellij.ui.ColoredListCellRenderer)1 ListSpeedSearch (com.intellij.ui.ListSpeedSearch)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 JBList (com.intellij.ui.components.JBList)1 Convertor (com.intellij.util.containers.Convertor)1 List (java.util.List)1 JComponent (javax.swing.JComponent)1 JList (javax.swing.JList)1 VERTICAL (javax.swing.JList.VERTICAL)1 JPanel (javax.swing.JPanel)1 ListSelectionModel (javax.swing.ListSelectionModel)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 Organization (org.sonarqube.ws.Organizations.Organization)1 WsHelperImpl (org.sonarsource.sonarlint.core.WsHelperImpl)1 WsHelper (org.sonarsource.sonarlint.core.client.api.connected.WsHelper)1