Search in sources :

Example 16 with ServerApiHelper

use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.

the class ConnectedSonarLintEngineImpl method update.

@Override
public UpdateResult update(EndpointParams endpoint, HttpClient client, @Nullable ClientProgressMonitor monitor) {
    requireNonNull(endpoint);
    setLogging(null);
    globalStorageUpdateExecutor.update(new ServerApiHelper(endpoint, client), new ProgressMonitor(monitor));
    return new UpdateResult(globalStatusReader.read());
}
Also used : ClientProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor) ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApiHelper(org.sonarsource.sonarlint.core.serverapi.ServerApiHelper) UpdateResult(org.sonarsource.sonarlint.core.client.api.connected.UpdateResult)

Example 17 with ServerApiHelper

use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.

the class OrganizationApiTests method should_throw_if_server_is_down.

@Test
void should_throw_if_server_is_down() {
    mockServer.addStringResponse("/api/system/status", "{" + "\"status\": \"DOWN\"," + "\"version\": \"20.0.0\"" + "}");
    var underTest = new OrganizationApi(new ServerApiHelper(mockServer.endpointParams(), MockWebServerExtension.httpClient()));
    var throwable = catchThrowable(() -> underTest.getOrganization("org:key", progressMonitor));
    assertThat(throwable).isInstanceOf(IllegalStateException.class).hasMessage("Server not ready (DOWN)");
}
Also used : ServerApiHelper(org.sonarsource.sonarlint.core.serverapi.ServerApiHelper) Test(org.junit.jupiter.api.Test)

Example 18 with ServerApiHelper

use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.

the class OrganizationApiTests method should_get_organization_details.

@Test
void should_get_organization_details() {
    mockServer.addStringResponse("/api/system/status", "{" + "\"status\": \"UP\"," + "\"version\": \"20.0.0\"" + "}");
    mockServer.addProtobufResponse("/api/organizations/search.protobuf?organizations=org%3Akey&ps=500&p=1", SearchWsResponse.newBuilder().addOrganizations(Organization.newBuilder().setKey("orgKey").setName("orgName").setDescription("orgDesc").build()).build());
    mockServer.addProtobufResponse("/api/organizations/search.protobuf?organizations=org%3Akey&ps=500&p=2", SearchWsResponse.newBuilder().build());
    var underTest = new OrganizationApi(new ServerApiHelper(mockServer.endpointParams(), MockWebServerExtension.httpClient()));
    var organization = underTest.getOrganization("org:key", progressMonitor);
    assertThat(organization).hasValueSatisfying(org -> {
        assertThat(org.getKey()).isEqualTo("orgKey");
        assertThat(org.getName()).isEqualTo("orgName");
        assertThat(org.getDescription()).isEqualTo("orgDesc");
    });
}
Also used : ServerApiHelper(org.sonarsource.sonarlint.core.serverapi.ServerApiHelper) Test(org.junit.jupiter.api.Test)

Aggregations

ServerApiHelper (org.sonarsource.sonarlint.core.serverapi.ServerApiHelper)18 Test (org.junit.jupiter.api.Test)10 ClientProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor)4 ProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor)4 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 PluginDetails (org.sonarsource.sonarlint.core.client.api.common.PluginDetails)2 ConnectedGlobalConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ConnectedGlobalConfiguration)2 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)2 ConnectionValidator (org.sonarsource.sonarlint.core.client.api.connected.ConnectionValidator)2 UpdateResult (org.sonarsource.sonarlint.core.client.api.connected.UpdateResult)2 StorageException (org.sonarsource.sonarlint.core.client.api.exceptions.StorageException)2 Orchestrator (com.sonar.orchestrator.Orchestrator)1 MavenLocation (com.sonar.orchestrator.locator.MavenLocation)1 SONAR_VERSION (its.tools.ItUtils.SONAR_VERSION)1 Paths (java.nio.file.Paths)1 Collection (java.util.Collection)1 Collections.emptySet (java.util.Collections.emptySet)1