use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class LiveIssueCacheTest method should_clear_store.
@Test
public void should_clear_store() {
LiveIssue issue1 = createTestIssue("r1");
VirtualFile file0 = createTestFile("file0");
cache.save(file0, Collections.singleton(issue1));
cache.clear();
verify(store).clear();
assertThat(cache.getLive(file0)).isNull();
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class LiveIssueCacheTest method error_flush.
@Test
public void error_flush() throws IOException {
doThrow(new IOException()).when(store).save(anyString(), anyCollection());
LiveIssue issue1 = createTestIssue("r1");
VirtualFile file0 = createTestFile("file0");
cache.save(file0, Collections.singleton(issue1));
exception.expect(IllegalStateException.class);
cache.flushAll();
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class LiveIssueCacheTest method should_flush_on_project_closed.
@Test
public void should_flush_on_project_closed() 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.disposeComponent();
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 should_save_and_read_cache_only.
@Test
public void should_save_and_read_cache_only() throws IOException {
VirtualFile file = createTestFile("file1");
LiveIssue issue1 = createTestIssue("will be overwritten");
LiveIssue issue2 = createTestIssue("r1");
cache.save(file, Collections.singleton(issue1));
cache.save(file, Collections.singleton(issue2));
assertThat(cache.contains(file)).isTrue();
assertThat(cache.getLive(file)).containsOnly(issue2);
assertThat(cache.contains(createTestFile("file2"))).isFalse();
verifyZeroInteractions(store);
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class IssueTree method navigate.
@CheckForNull
private OpenFileDescriptor navigate() {
DefaultMutableTreeNode node = getSelectedNode();
if (!(node instanceof IssueNode)) {
return null;
}
LiveIssue issue = ((IssueNode) node).issue();
if (!issue.isValid()) {
return null;
}
int offset;
RangeMarker range = issue.getRange();
if (range != null) {
offset = range.getStartOffset();
} else {
offset = 0;
}
return new OpenFileDescriptor(project, issue.psiFile().getVirtualFile(), offset);
}
Aggregations