Search in sources :

Example 1 with LiveIssue

use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.

the class SonarLintCheckinHandlerTest method testIssues.

@Test
public void testIssues() {
    future.complete(null);
    LiveIssue issue = mock(LiveIssue.class);
    when(issueManager.getForFile(file)).thenReturn(Collections.singleton(issue));
    handler = new SonarLintCheckinHandler(globalSettings, project, checkinProjectPanel);
    CheckinHandler.ReturnResult result = handler.beforeCheckin(null, null);
    assertThat(result).isEqualTo(CheckinHandler.ReturnResult.CANCEL);
    verify(analysisResultIssues).set(anyMap(), eq("SCM changed files"));
    verify(submitter).submitFilesModal(eq(Collections.singleton(file)), eq(TriggerType.CHECK_IN), any(AnalysisCallback.class));
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) AnalysisCallback(org.sonarlint.intellij.analysis.AnalysisCallback) CheckinHandler(com.intellij.openapi.vcs.checkin.CheckinHandler) SonarTest(org.sonarlint.intellij.SonarTest) Test(org.junit.Test)

Example 2 with LiveIssue

use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.

the class IssueNodeTest method testHoursAndSeverity.

@Test
public void testHoursAndSeverity() throws IOException {
    LiveIssue i = createIssue(System.currentTimeMillis() - 3600 * 1000, "rule");
    node = new IssueNode(i);
    node.render(renderer);
    verify(renderer).append("1 hour ago", SimpleTextAttributes.GRAY_ATTRIBUTES);
    verify(renderer).append("rule");
    verify(renderer).setIcon(SonarLintIcons.severity("MAJOR"));
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) Test(org.junit.Test)

Example 3 with LiveIssue

use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.

the class IssueNodeTest method testInvalidIssue.

@Test
public void testInvalidIssue() {
    LiveIssue i = createIssue(System.currentTimeMillis(), "rule");
    when(i.isValid()).thenReturn(false);
    node = new IssueNode(i);
    node.render(renderer);
    verify(renderer).append("rule", SimpleTextAttributes.GRAY_ATTRIBUTES);
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) Test(org.junit.Test)

Example 4 with LiveIssue

use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.

the class IssueNodeTest method testAge.

@Test
public void testAge() {
    LiveIssue i = createIssue(System.currentTimeMillis(), "rule");
    node = new IssueNode(i);
    node.render(renderer);
    verify(renderer).append("few seconds ago", SimpleTextAttributes.GRAY_ATTRIBUTES);
    verify(renderer).append("rule");
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) Test(org.junit.Test)

Example 5 with LiveIssue

use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.

the class IssueNodeTest method testCount.

@Test
public void testCount() {
    LiveIssue i = createIssue(System.currentTimeMillis(), "rule");
    node = new IssueNode(i);
    assertThat(node.getFileCount()).isZero();
    assertThat(node.getIssueCount()).isEqualTo(1);
    assertThat(node.issue()).isEqualTo(i);
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) Test(org.junit.Test)

Aggregations

LiveIssue (org.sonarlint.intellij.issue.LiveIssue)26 Test (org.junit.Test)15 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 RangeMarker (com.intellij.openapi.editor.RangeMarker)4 PsiFile (com.intellij.psi.PsiFile)4 CheckinHandler (com.intellij.openapi.vcs.checkin.CheckinHandler)3 AnalysisCallback (org.sonarlint.intellij.analysis.AnalysisCallback)3 IssueNode (org.sonarlint.intellij.ui.nodes.IssueNode)3 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 UIUtil (com.intellij.util.ui.UIUtil)2 IOException (java.io.IOException)2 Collection (java.util.Collection)2 SonarTest (org.sonarlint.intellij.SonarTest)2 IssueManager (org.sonarlint.intellij.issue.IssueManager)2 SonarLintUtils (org.sonarlint.intellij.util.SonarLintUtils)2 Issue (org.sonarsource.sonarlint.core.client.api.common.analysis.Issue)2 InspectionDescriptionLinkHandler (com.intellij.codeInsight.hint.InspectionDescriptionLinkHandler)1 ProblemHighlightType (com.intellij.codeInspection.ProblemHighlightType)1