use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusCheckerTest method responseParsingError.
@Test
public void responseParsingError() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/system/status", "bla bla");
ServerVersionAndStatusChecker checker = new ServerVersionAndStatusChecker(wsClient);
try {
checker.checkVersionAndStatus();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessage("Unable to parse server infos from: bla bla");
}
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusCheckerTest method fallbackOnDeprecatedWs_if_404.
@Test
public void fallbackOnDeprecatedWs_if_404() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/server/version", "4.5");
WsClientTestUtils.addFailedResponse(wsClient, "api/system/status", HttpURLConnection.HTTP_NOT_FOUND, "");
ServerVersionAndStatusChecker checker = new ServerVersionAndStatusChecker(wsClient);
try {
checker.checkVersionAndStatus();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isExactlyInstanceOf(UnsupportedServerException.class).hasMessage("SonarQube server has version 4.5. Version should be greater or equal to 5.6");
}
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class WsHelperImpl method listOrganizations.
@Override
public List<RemoteOrganization> listOrganizations(ServerConfiguration serverConfig, @Nullable ProgressMonitor monitor) {
SonarLintWsClient client = createClient(serverConfig);
ServerVersionAndStatusChecker serverChecker = new ServerVersionAndStatusChecker(client);
return listOrganizations(client, serverChecker, new ProgressWrapper(monitor));
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class NotificationCheckerTest method testFailCode.
@Test
public void testFailCode() {
ZonedDateTime timestamp = ZonedDateTime.of(2017, 06, 04, 20, 0, 0, 0, ZoneOffset.ofHours(0));
String expectedUrl = "api/developers/search_events?projects=myproject&from=2017-06-04T20%3A00%3A00%2B0000";
SonarLintWsClient client = WsClientTestUtils.createMock();
WsClientTestUtils.addFailedResponse(client, expectedUrl, 404, "failed");
NotificationChecker checker = new NotificationChecker(client);
List<SonarQubeNotification> notifications = checker.request(Collections.singletonMap("myproject", timestamp));
assertThat(notifications).isEmpty();
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class NotificationCheckerTest method testFailParsing.
@Test
public void testFailParsing() {
ZonedDateTime timestamp = ZonedDateTime.of(2017, 06, 04, 20, 0, 0, 0, ZoneOffset.ofHours(0));
String expectedUrl = "api/developers/search_events?projects=myproject&from=2017-06-04T20%3A00%3A00%2B0000";
SonarLintWsClient client = WsClientTestUtils.createMockWithResponse(expectedUrl, INVALID_RESPONSE);
NotificationChecker checker = new NotificationChecker(client);
List<SonarQubeNotification> notifications = checker.request(Collections.singletonMap("myproject", timestamp));
assertThat(notifications).isEmpty();
}
Aggregations