Search in sources :

Example 1 with TaskListener

use of org.sonarlint.intellij.messages.TaskListener in project sonarlint-intellij by SonarSource.

the class SonarLintTaskTest method testCallListenerOnError.

@Test
public void testCallListenerOnError() {
    TaskListener listener = mock(TaskListener.class);
    getProject().getMessageBus().connect(getProject()).subscribe(TaskListener.SONARLINT_TASK_TOPIC, listener);
    doThrow(new IllegalStateException("error")).when(sonarLintAnalyzer).analyzeModule(eq(module), eq(files), any(IssueListener.class), any(ProgressMonitor.class));
    task.run(progress);
    // never called because of error
    verifyZeroInteractions(processor);
    // still called
    verify(listener).ended(job);
    verifyNoMoreInteractions(listener);
}
Also used : ProgressMonitor(org.sonarsource.sonarlint.core.client.api.common.ProgressMonitor) IssueListener(org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener) TaskListener(org.sonarlint.intellij.messages.TaskListener) SonarTest(org.sonarlint.intellij.SonarTest) Test(org.junit.Test)

Example 2 with TaskListener

use of org.sonarlint.intellij.messages.TaskListener in project sonarlint-intellij by SonarSource.

the class SonarLintTaskTest method testTask.

@Test
public void testTask() {
    TaskListener listener = mock(TaskListener.class);
    getProject().getMessageBus().connect(getProject()).subscribe(TaskListener.SONARLINT_TASK_TOPIC, listener);
    assertThat(task.shouldStartInBackground()).isTrue();
    assertThat(task.isConditionalModal()).isFalse();
    assertThat(task.getJob()).isEqualTo(job);
    task.run(progress);
    verify(sonarLintAnalyzer).analyzeModule(eq(module), eq(files), any(IssueListener.class), any(ProgressMonitor.class));
    verify(processor).process(job, progress, new ArrayList<>(), new ArrayList<>());
    verify(listener).ended(job);
    verifyNoMoreInteractions(sonarLintAnalyzer);
    verifyNoMoreInteractions(processor);
}
Also used : ProgressMonitor(org.sonarsource.sonarlint.core.client.api.common.ProgressMonitor) IssueListener(org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener) TaskListener(org.sonarlint.intellij.messages.TaskListener) SonarTest(org.sonarlint.intellij.SonarTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 SonarTest (org.sonarlint.intellij.SonarTest)2 TaskListener (org.sonarlint.intellij.messages.TaskListener)2 ProgressMonitor (org.sonarsource.sonarlint.core.client.api.common.ProgressMonitor)2 IssueListener (org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener)2