Search in sources :

Example 21 with SonarLintWsClient

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);
}
Also used : IssueDownloader(org.sonarsource.sonarlint.core.container.connected.update.IssueDownloader) IssueDownloaderImpl(org.sonarsource.sonarlint.core.container.connected.update.IssueDownloaderImpl) ModuleListDownloader(org.sonarsource.sonarlint.core.container.connected.update.ModuleListDownloader) IssueStoreFactory(org.sonarsource.sonarlint.core.container.connected.IssueStoreFactory) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)

Example 22 with SonarLintWsClient

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

Example 23 with SonarLintWsClient

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)));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) SonarQubeNotification(org.sonarsource.sonarlint.core.client.api.notifications.SonarQubeNotification) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 24 with SonarLintWsClient

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();
}
Also used : WsResponse(org.sonarsource.sonarlint.core.util.ws.WsResponse) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 25 with SonarLintWsClient

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();
}
Also used : WsResponse(org.sonarsource.sonarlint.core.util.ws.WsResponse) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Aggregations

SonarLintWsClient (org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)40 Test (org.junit.Test)37 ProgressWrapper (org.sonarsource.sonarlint.core.util.ProgressWrapper)8 File (java.io.File)7 UnsupportedServerException (org.sonarsource.sonarlint.core.client.api.exceptions.UnsupportedServerException)6 NotFoundException (org.sonarsource.sonarlint.core.container.connected.exceptions.NotFoundException)6 ValidationResult (org.sonarsource.sonarlint.core.client.api.connected.ValidationResult)5 StringReader (java.io.StringReader)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ZonedDateTime (java.time.ZonedDateTime)3 SonarQubeNotification (org.sonarsource.sonarlint.core.client.api.notifications.SonarQubeNotification)3 ActiveRules (org.sonarsource.sonarlint.core.proto.Sonarlint.ActiveRules)3 Builder (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder)3 ModuleList (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList)3 Rules (org.sonarsource.sonarlint.core.proto.Sonarlint.Rules)3 InputStream (java.io.InputStream)2 PipedInputStream (java.io.PipedInputStream)2 PipedOutputStream (java.io.PipedOutputStream)2 ValuesWsResponse (org.sonarqube.ws.Settings.ValuesWsResponse)2 GlobalProperties (org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties)2