Search in sources :

Example 6 with IssuableSubscriptionVisitor

use of org.sonar.plugins.java.api.IssuableSubscriptionVisitor in project sonar-java by SonarSource.

the class JavaCheckVerifierTest method verify_combined_missing_expected_and_unexpected_issues.

@Test
public void verify_combined_missing_expected_and_unexpected_issues() {
    IssuableSubscriptionVisitor visitor = new FakeVisitor().withDefaultIssues().withIssue(4, "extra message").withoutIssue(1);
    try {
        JavaCheckVerifier.verify(FILENAME_ISSUES, visitor);
        Fail.fail("");
    } catch (AssertionError e) {
        assertThat(e).hasMessage("Expected at [1], Unexpected at [4]");
    }
}
Also used : IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) Test(org.junit.Test)

Example 7 with IssuableSubscriptionVisitor

use of org.sonar.plugins.java.api.IssuableSubscriptionVisitor in project sonar-java by SonarSource.

the class JavaCheckVerifierTest method verify_with_provided_classes.

@Test
public void verify_with_provided_classes() {
    IssuableSubscriptionVisitor visitor = new FakeVisitor().withDefaultIssues();
    JavaCheckVerifier.verify(FILENAME_ISSUES, visitor, new ArrayList<File>());
}
Also used : IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) File(java.io.File) Test(org.junit.Test)

Example 8 with IssuableSubscriptionVisitor

use of org.sonar.plugins.java.api.IssuableSubscriptionVisitor in project sonar-java by SonarSource.

the class JavaCheckVerifierTest method verify_line_issues.

@Test
public void verify_line_issues() {
    IssuableSubscriptionVisitor visitor = new FakeVisitor().withDefaultIssues();
    JavaCheckVerifier.verify("src/test/files/JavaCheckVerifier.java", visitor);
}
Also used : IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) Test(org.junit.Test)

Example 9 with IssuableSubscriptionVisitor

use of org.sonar.plugins.java.api.IssuableSubscriptionVisitor in project sonar-java by SonarSource.

the class JavaCheckVerifierTest method verify_should_fail_when_using_incorrect_secondaryLocation2.

@Test
public void verify_should_fail_when_using_incorrect_secondaryLocation2() throws IOException {
    IssuableSubscriptionVisitor visitor = new FakeVisitor().withDefaultIssues();
    try {
        JavaCheckVerifier.verify("src/test/files/JavaCheckVerifierIncorrectSecondaryLocation2.java", visitor);
        Fail.fail("");
    } catch (AssertionError e) {
        assertThat(e).hasMessage("Secondary locations: expected: [5] unexpected:[]");
    }
}
Also used : IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) Test(org.junit.Test)

Example 10 with IssuableSubscriptionVisitor

use of org.sonar.plugins.java.api.IssuableSubscriptionVisitor in project sonar-java by SonarSource.

the class JavaCheckVerifierTest method verify_unexpected_issue.

@Test
public void verify_unexpected_issue() {
    IssuableSubscriptionVisitor visitor = new FakeVisitor().withDefaultIssues().withIssue(4, "extra message");
    try {
        JavaCheckVerifier.verify(FILENAME_ISSUES, visitor);
        Fail.fail("");
    } catch (AssertionError e) {
        assertThat(e).hasMessage("Unexpected at [4]");
    }
}
Also used : IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)24 IssuableSubscriptionVisitor (org.sonar.plugins.java.api.IssuableSubscriptionVisitor)24 File (java.io.File)5 Tree (org.sonar.plugins.java.api.tree.Tree)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1 Rule (org.junit.Rule)1 ExpectedException (org.junit.rules.ExpectedException)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 JavaAstScanner (org.sonar.java.ast.JavaAstScanner)1 SubscriptionVisitor (org.sonar.java.ast.visitors.SubscriptionVisitor)1 JavaTree (org.sonar.java.model.JavaTree)1