use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class SonarExternalAnnotatorTest method createRangeStoredIssue.
private LiveIssue createRangeStoredIssue(int id, int rangeStart, int rangeEnd, String text) {
Issue issue = SonarLintTestUtils.createIssue(id);
RangeMarker range = mock(RangeMarker.class);
when(range.getStartOffset()).thenReturn(rangeStart);
when(range.getEndOffset()).thenReturn(rangeEnd);
when(range.isValid()).thenReturn(true);
when(range.getDocument()).thenReturn(document);
when(document.getText(any(TextRange.class))).thenReturn(text);
return new LiveIssue(issue, null, range, Collections.emptyList());
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class LiveIssueCacheTest method error_remove_eldest.
@Test
public void error_remove_eldest() throws IOException {
doThrow(new IOException()).when(store).save(anyString(), anyCollection());
LiveIssue issue1 = createTestIssue("r1");
for (int i = 0; i < LiveIssueCache.MAX_ENTRIES; i++) {
VirtualFile file = createTestFile("file" + i);
cache.save(file, Collections.singleton(issue1));
}
exception.expect(IllegalStateException.class);
cache.save(createTestFile("anotherfile"), Collections.singleton(issue1));
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class LiveIssueCacheTest method should_flush_if_full.
@Test
public void should_flush_if_full() throws IOException {
LiveIssue issue1 = createTestIssue("r1");
VirtualFile file0 = createTestFile("file0");
cache.save(file0, Collections.singleton(issue1));
for (int i = 1; i < LiveIssueCache.MAX_ENTRIES; i++) {
VirtualFile file = createTestFile("file" + i);
cache.save(file, Collections.singleton(issue1));
}
// oldest access should be file1 after this
assertThat(cache.getLive(file0)).containsOnly(issue1);
verifyZeroInteractions(store);
VirtualFile file = createTestFile("anotherfile");
cache.save(file, Collections.singleton(issue1));
verify(store).save(eq("file1"), anyCollection());
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class LiveIssueCacheTest method should_flush_when_requested.
@Test
public void should_flush_when_requested() throws IOException {
LiveIssue issue1 = createTestIssue("r1");
VirtualFile file0 = createTestFile("file0");
cache.save(file0, Collections.singleton(issue1));
VirtualFile file1 = createTestFile("file1");
cache.save(file1, Collections.singleton(issue1));
cache.flushAll();
verify(store).save(eq("file0"), anyCollection());
verify(store).save(eq("file1"), anyCollection());
verifyNoMoreInteractions(store);
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class LiveIssueCacheTest method createTestIssue.
private LiveIssue createTestIssue(String ruleKey) {
LiveIssue issue = mock(LiveIssue.class);
when(issue.getRuleKey()).thenReturn(ruleKey);
when(issue.getAssignee()).thenReturn("assignee");
when(issue.getRuleName()).thenReturn(ruleKey);
when(issue.getSeverity()).thenReturn("MAJOR");
when(issue.getMessage()).thenReturn("msg");
return issue;
}
Aggregations