Search in sources :

Example 11 with FilePredicate

use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.

the class AndPredicateTest method simplifyAndExpressionsWhenEmpty.

@Test
public void simplifyAndExpressionsWhenEmpty() {
    FilePredicate andPredicate = AndPredicate.create(Arrays.<FilePredicate>asList());
    assertThat(andPredicate).isEqualTo(TruePredicate.TRUE);
}
Also used : FilePredicate(org.sonar.api.batch.fs.FilePredicate) Test(org.junit.Test)

Example 12 with FilePredicate

use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.

the class OrPredicateTest method simplifyOrExpressionsWhenFalse.

@Test
public void simplifyOrExpressionsWhenFalse() {
    PathPatternPredicate pathPatternPredicate1 = new PathPatternPredicate(PathPattern.create("foo1/**"));
    PathPatternPredicate pathPatternPredicate2 = new PathPatternPredicate(PathPattern.create("foo2/**"));
    FilePredicate andPredicate = OrPredicate.create(Arrays.<FilePredicate>asList(pathPatternPredicate1, FalsePredicate.FALSE, pathPatternPredicate2));
    assertThat(((OrPredicate) andPredicate).predicates()).containsExactly(pathPatternPredicate1, pathPatternPredicate2);
}
Also used : FilePredicate(org.sonar.api.batch.fs.FilePredicate) Test(org.junit.Test)

Example 13 with FilePredicate

use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.

the class OrPredicateTest method flattenNestedOr.

@Test
public void flattenNestedOr() {
    PathPatternPredicate pathPatternPredicate1 = new PathPatternPredicate(PathPattern.create("foo1/**"));
    PathPatternPredicate pathPatternPredicate2 = new PathPatternPredicate(PathPattern.create("foo2/**"));
    PathPatternPredicate pathPatternPredicate3 = new PathPatternPredicate(PathPattern.create("foo3/**"));
    FilePredicate orPredicate = OrPredicate.create(Arrays.<FilePredicate>asList(pathPatternPredicate1, OrPredicate.create(Arrays.<FilePredicate>asList(pathPatternPredicate2, pathPatternPredicate3))));
    assertThat(((OrPredicate) orPredicate).predicates()).containsExactly(pathPatternPredicate1, pathPatternPredicate2, pathPatternPredicate3);
}
Also used : FilePredicate(org.sonar.api.batch.fs.FilePredicate) Test(org.junit.Test)

Example 14 with FilePredicate

use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.

the class OrPredicateTest method simplifyOrExpressionsWhenEmpty.

@Test
public void simplifyOrExpressionsWhenEmpty() {
    FilePredicate orPredicate = OrPredicate.create(Arrays.<FilePredicate>asList());
    assertThat(orPredicate).isEqualTo(TruePredicate.TRUE);
}
Also used : FilePredicate(org.sonar.api.batch.fs.FilePredicate) Test(org.junit.Test)

Aggregations

FilePredicate (org.sonar.api.batch.fs.FilePredicate)14 Test (org.junit.Test)10 InputFile (org.sonar.api.batch.fs.InputFile)3 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)1 NewIssue (org.sonar.api.batch.sensor.issue.NewIssue)1 RuleKey (org.sonar.api.rule.RuleKey)1