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());
}
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)");
}
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");
});
}
Aggregations