Search in sources :

Example 16 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:[]. In src/test/files/JavaCheckVerifierIncorrectSecondaryLocation2.java:10");
    }
}
Also used : IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) Test(org.junit.Test)

Example 17 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 18 with IssuableSubscriptionVisitor

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

the class JavaCheckVerifierTest method should_fail_when_no_cost.

@Test
public void should_fail_when_no_cost() throws Exception {
    IssuableSubscriptionVisitor visitor = new LinearFakeVisitor().withDefaultIssues();
    try {
        JavaCheckVerifier.verify(FILENAME_ISSUES, visitor);
        Fail.fail("");
    } catch (AssertionError e) {
        assertThat(e).hasMessage("A cost should be provided for a rule with linear remediation function");
    }
}
Also used : IssuableSubscriptionVisitor(org.sonar.plugins.java.api.IssuableSubscriptionVisitor) Test(org.junit.Test)

Example 19 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_secondaryLocation.

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

Example 20 with IssuableSubscriptionVisitor

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

the class JavaCheckVerifierTest method verify_issue_on_file.

@Test
public void verify_issue_on_file() {
    String expectedMessage = "messageOnFile";
    IssuableSubscriptionVisitor visitor = new FakeVisitor().withIssueOnFile(expectedMessage);
    JavaCheckVerifier.verifyIssueOnFile(FILENAME_ISSUES, expectedMessage, visitor);
}
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