Search in sources :

Example 6 with Issue

use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue in project sonarlint-core by SonarSource.

the class ProxyIssueListenerTest method testWithSeverity.

private void testWithSeverity(Severity severity) {
    StreamObserver<Issue> observer = mock(StreamObserver.class);
    ClientInputFile inputFile = mock(ClientInputFile.class);
    when(inputFile.getPath()).thenReturn("filename");
    when(inputFile.getClientObject()).thenReturn("obj");
    ProxyIssueListener listener = new ProxyIssueListener(observer);
    org.sonarsource.sonarlint.core.client.api.common.analysis.Issue i = mock(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue.class);
    when(i.getEndLine()).thenReturn(10);
    when(i.getStartLine()).thenReturn(11);
    when(i.getStartLineOffset()).thenReturn(12);
    when(i.getEndLineOffset()).thenReturn(13);
    when(i.getMessage()).thenReturn("msg");
    when(i.getRuleKey()).thenReturn("key");
    when(i.getRuleName()).thenReturn("name");
    when(i.getSeverity()).thenReturn(severity.toString().toUpperCase());
    when(i.getInputFile()).thenReturn(inputFile);
    listener.handle(i);
    ArgumentCaptor<Issue> argument = ArgumentCaptor.forClass(Issue.class);
    verify(observer).onNext(argument.capture());
    Issue captured = argument.getValue();
    assertThat(captured.getEndLine()).isEqualTo(10);
    assertThat(captured.getStartLine()).isEqualTo(11);
    assertThat(captured.getStartLineOffset()).isEqualTo(12);
    assertThat(captured.getEndLineOffset()).isEqualTo(13);
    assertThat(captured.getMessage()).isEqualTo("msg");
    assertThat(captured.getRuleKey()).isEqualTo("key");
    assertThat(captured.getRuleName()).isEqualTo("name");
    assertThat(captured.getSeverity()).isEqualTo(severity);
    assertThat(captured.getFilePath()).isEqualTo("filename");
    assertThat(captured.getUserObject()).isEqualTo("obj");
}
Also used : Issue(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)

Example 7 with Issue

use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue in project sonarlint-core by SonarSource.

the class ProxyIssueListenerTest method dont_fail_if_no_user_obj.

@Test
public void dont_fail_if_no_user_obj() {
    StreamObserver<Issue> observer = mock(StreamObserver.class);
    ClientInputFile inputFile = mock(ClientInputFile.class);
    when(inputFile.getPath()).thenReturn("filename");
    ProxyIssueListener listener = new ProxyIssueListener(observer);
    org.sonarsource.sonarlint.core.client.api.common.analysis.Issue i = mock(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue.class);
    when(i.getEndLine()).thenReturn(10);
    when(i.getStartLine()).thenReturn(11);
    when(i.getStartLineOffset()).thenReturn(12);
    when(i.getEndLineOffset()).thenReturn(13);
    when(i.getMessage()).thenReturn("msg");
    when(i.getRuleKey()).thenReturn("key");
    when(i.getRuleName()).thenReturn("name");
    when(i.getSeverity()).thenReturn("MINOR");
    when(i.getInputFile()).thenReturn(inputFile);
    listener.handle(i);
    ArgumentCaptor<Issue> argument = ArgumentCaptor.forClass(Issue.class);
    verify(observer).onNext(argument.capture());
    Issue captured = argument.getValue();
    assertThat(captured.getEndLine()).isEqualTo(10);
    assertThat(captured.getStartLine()).isEqualTo(11);
    assertThat(captured.getStartLineOffset()).isEqualTo(12);
    assertThat(captured.getEndLineOffset()).isEqualTo(13);
    assertThat(captured.getMessage()).isEqualTo("msg");
    assertThat(captured.getRuleKey()).isEqualTo("key");
    assertThat(captured.getRuleName()).isEqualTo("name");
    assertThat(captured.getSeverity()).isEqualTo(Severity.MINOR);
    assertThat(captured.getFilePath()).isEqualTo("filename");
    assertThat(captured.getUserObject()).isEqualTo("");
}
Also used : Issue(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) Test(org.junit.Test)

Aggregations

Issue (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue)7 Test (org.junit.Test)4 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)4 ManagedChannel (io.grpc.ManagedChannel)2 ConnectedSonarLintBlockingStub (org.sonarsource.sonarlint.daemon.proto.ConnectedSonarLintGrpc.ConnectedSonarLintBlockingStub)2 LogEvent (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.LogEvent)2 Void (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Void)2 AnalysisReq (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.AnalysisReq)1 Severity (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue.Severity)1 Type (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue.Type)1 ModuleUpdateReq (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.ModuleUpdateReq)1 ServerConfig (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.ServerConfig)1 StandaloneSonarLintBlockingStub (org.sonarsource.sonarlint.daemon.proto.StandaloneSonarLintGrpc.StandaloneSonarLintBlockingStub)1