Search in sources :

Example 1 with IssueListener

use of org.sonar.batch.bootstrapper.IssueListener in project sonarqube by SonarSource.

the class DefaultIssueCallbackTest method testWithListener.

@Test
public void testWithListener() {
    final List<IssueListener.Issue> issueList = new LinkedList<>();
    IssueListener listener = new IssueListener() {

        @Override
        public void handle(Issue issue) {
            issueList.add(issue);
        }
    };
    DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, userRepository, rules);
    issueCallback.execute();
    assertThat(issueList).hasSize(1);
    Issue callbackIssue = issueList.get(0);
    assertThat(callbackIssue.getAssigneeName()).isEqualTo("name");
    assertThat(callbackIssue.getRuleName()).isEqualTo("rule name");
}
Also used : Issue(org.sonar.batch.bootstrapper.IssueListener.Issue) TrackedIssue(org.sonar.scanner.issue.tracking.TrackedIssue) IssueListener(org.sonar.batch.bootstrapper.IssueListener) DefaultIssueCallback(org.sonar.scanner.issue.DefaultIssueCallback) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with IssueListener

use of org.sonar.batch.bootstrapper.IssueListener in project sonarqube by SonarSource.

the class DefaultIssueCallbackTest method testDecorationNotFound.

@Test
public void testDecorationNotFound() {
    final List<IssueListener.Issue> issueList = new LinkedList<>();
    IssueListener listener = new IssueListener() {

        @Override
        public void handle(Issue issue) {
            issueList.add(issue);
        }
    };
    when(userRepository.load(any(String.class))).thenReturn(null);
    when(rules.find(any(RuleKey.class))).thenReturn(null);
    DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, userRepository, rules);
    issueCallback.execute();
}
Also used : Issue(org.sonar.batch.bootstrapper.IssueListener.Issue) TrackedIssue(org.sonar.scanner.issue.tracking.TrackedIssue) IssueListener(org.sonar.batch.bootstrapper.IssueListener) RuleKey(org.sonar.api.rule.RuleKey) DefaultIssueCallback(org.sonar.scanner.issue.DefaultIssueCallback) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with IssueListener

use of org.sonar.batch.bootstrapper.IssueListener in project sonarqube by SonarSource.

the class DefaultIssueCallbackTest method testWithNulls.

@Test
public void testWithNulls() {
    final List<IssueListener.Issue> issueList = new LinkedList<>();
    IssueListener listener = new IssueListener() {

        @Override
        public void handle(Issue issue) {
            issueList.add(issue);
        }
    };
    issue.setKey(null);
    issue.setAssignee(null);
    DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, userRepository, rules);
    issueCallback.execute();
}
Also used : Issue(org.sonar.batch.bootstrapper.IssueListener.Issue) TrackedIssue(org.sonar.scanner.issue.tracking.TrackedIssue) IssueListener(org.sonar.batch.bootstrapper.IssueListener) DefaultIssueCallback(org.sonar.scanner.issue.DefaultIssueCallback) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

LinkedList (java.util.LinkedList)3 Test (org.junit.Test)3 IssueListener (org.sonar.batch.bootstrapper.IssueListener)3 Issue (org.sonar.batch.bootstrapper.IssueListener.Issue)3 DefaultIssueCallback (org.sonar.scanner.issue.DefaultIssueCallback)3 TrackedIssue (org.sonar.scanner.issue.tracking.TrackedIssue)3 RuleKey (org.sonar.api.rule.RuleKey)1