use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.
the class AndPredicateTest method flattenNestedAnd.
@Test
public void flattenNestedAnd() {
PathPatternPredicate pathPatternPredicate1 = new PathPatternPredicate(PathPattern.create("foo1/**"));
PathPatternPredicate pathPatternPredicate2 = new PathPatternPredicate(PathPattern.create("foo2/**"));
PathPatternPredicate pathPatternPredicate3 = new PathPatternPredicate(PathPattern.create("foo3/**"));
FilePredicate andPredicate = AndPredicate.create(Arrays.<FilePredicate>asList(pathPatternPredicate1, AndPredicate.create(Arrays.<FilePredicate>asList(pathPatternPredicate2, pathPatternPredicate3))));
assertThat(((AndPredicate) andPredicate).predicates()).containsExactly(pathPatternPredicate1, pathPatternPredicate2, pathPatternPredicate3);
}
use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.
the class AndPredicateTest method simplifyAndExpressionsWhenTrue.
@Test
public void simplifyAndExpressionsWhenTrue() {
PathPatternPredicate pathPatternPredicate1 = new PathPatternPredicate(PathPattern.create("foo1/**"));
PathPatternPredicate pathPatternPredicate2 = new PathPatternPredicate(PathPattern.create("foo2/**"));
FilePredicate andPredicate = AndPredicate.create(Arrays.<FilePredicate>asList(pathPatternPredicate1, TruePredicate.TRUE, pathPatternPredicate2));
assertThat(((AndPredicate) andPredicate).predicates()).containsExactly(pathPatternPredicate1, pathPatternPredicate2);
}
use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.
the class OrPredicateTest method simplifyAndExpressionsWhenTrue.
@Test
public void simplifyAndExpressionsWhenTrue() {
PathPatternPredicate pathPatternPredicate1 = new PathPatternPredicate(PathPattern.create("foo1/**"));
PathPatternPredicate pathPatternPredicate2 = new PathPatternPredicate(PathPattern.create("foo2/**"));
FilePredicate andPredicate = OrPredicate.create(Arrays.<FilePredicate>asList(pathPatternPredicate1, TruePredicate.TRUE, pathPatternPredicate2));
assertThat(andPredicate).isEqualTo(TruePredicate.TRUE);
}
use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.
the class SensorOptimizer method fsCondition.
private boolean fsCondition(DefaultSensorDescriptor descriptor) {
if (!descriptor.languages().isEmpty() || descriptor.type() != null) {
FilePredicate langPredicate = descriptor.languages().isEmpty() ? fs.predicates().all() : fs.predicates().hasLanguages(descriptor.languages());
FilePredicate typePredicate = descriptor.type() == null ? fs.predicates().all() : fs.predicates().hasType(descriptor.type());
return fs.hasFiles(fs.predicates().and(langPredicate, typePredicate));
}
return true;
}
use of org.sonar.api.batch.fs.FilePredicate in project sonarqube by SonarSource.
the class AdditionalFilePredicatesTest method key.
@Test
public void key() {
FilePredicate predicate = new AdditionalFilePredicates.KeyPredicate("struts:Action.java");
InputFile inputFile = new TestInputFileBuilder("struts", "Action.java").build();
assertThat(predicate.apply(inputFile)).isTrue();
inputFile = new TestInputFileBuilder("struts", "Filter.java").build();
assertThat(predicate.apply(inputFile)).isFalse();
}
Aggregations