use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class PartialUpdater method create.
public static PartialUpdater create(StorageReader storageReader, StoragePaths storagePaths, ServerConfiguration serverConfig, IssueStoreReader issueStoreReader) {
SonarLintWsClient client = new SonarLintWsClient(serverConfig);
IssueStoreFactory issueStoreFactory = new IssueStoreFactory();
IssueDownloader downloader = new IssueDownloaderImpl(client);
ModuleListDownloader moduleListDownloader = new ModuleListDownloader(client);
return new PartialUpdater(issueStoreFactory, downloader, storageReader, storagePaths, issueStoreReader, moduleListDownloader);
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class WsClientTestUtils method createMock.
public static SonarLintWsClient createMock() {
SonarLintWsClient wsClient = mock(SonarLintWsClient.class);
when(wsClient.getUserAgent()).thenReturn("UT");
return wsClient;
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class NotificationCheckerTest method testSuccess.
@Test
public void testSuccess() {
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, VALID_RESPONSE);
NotificationChecker checker = new NotificationChecker(client);
List<SonarQubeNotification> notifications = checker.request(Collections.singletonMap("myproject", timestamp));
assertThat(notifications.size()).isEqualTo(2);
assertThat(notifications.get(0).category()).isEqualTo("QUALITY_GATE");
assertThat(notifications.get(0).message()).isEqualTo("Quality Gate is Red (was Orange)");
assertThat(notifications.get(0).link()).isEqualTo("https://sonarcloud.io/dashboard?id=myproject");
assertThat(notifications.get(0).projectKey()).isEqualTo("myproject");
assertThat(notifications.get(0).time()).isEqualTo(ZonedDateTime.of(2017, 7, 17, 9, 55, 26, 0, ZoneOffset.ofHours(2)));
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class NotificationCheckerTest method testIsNotSupported.
@Test
public void testIsNotSupported() {
String expectedUrl = "api/developers/search_events?projects=&from=";
SonarLintWsClient client = WsClientTestUtils.createMock();
WsResponse wsResponse = mock(WsResponse.class);
when(client.rawGet(startsWith(expectedUrl))).thenReturn(wsResponse);
when(wsResponse.isSuccessful()).thenReturn(false);
NotificationChecker checker = new NotificationChecker(client);
assertThat(checker.isSupported()).isFalse();
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class NotificationCheckerTest method testIsSupported.
@Test
public void testIsSupported() {
String expectedUrl = "api/developers/search_events?projects=&from=";
SonarLintWsClient client = WsClientTestUtils.createMock();
WsResponse wsResponse = mock(WsResponse.class);
when(client.rawGet(startsWith(expectedUrl))).thenReturn(wsResponse);
when(wsResponse.isSuccessful()).thenReturn(true);
NotificationChecker checker = new NotificationChecker(client);
assertThat(checker.isSupported()).isTrue();
}
Aggregations