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