Search in sources :

Example 6 with PathPattern

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

the class PathPatternTest method match_absolute_path_and_insensitive_file_extension.

@Test
public void match_absolute_path_and_insensitive_file_extension() {
    PathPattern pattern = PathPattern.create("file:**/src/main/**Foo.java");
    assertThat(pattern.toString()).isEqualTo("file:**/src/main/**Foo.java");
    IndexedFile indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/MyFoo.JAVA", null);
    assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()), false)).isTrue();
    indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/Other.JAVA", null);
    assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()), false)).isFalse();
}
Also used : PathPattern(org.sonar.api.batch.fs.internal.PathPattern) IndexedFile(org.sonar.api.batch.fs.IndexedFile) DefaultIndexedFile(org.sonar.api.batch.fs.internal.DefaultIndexedFile) DefaultIndexedFile(org.sonar.api.batch.fs.internal.DefaultIndexedFile) Test(org.junit.Test)

Aggregations

PathPattern (org.sonar.api.batch.fs.internal.PathPattern)6 Test (org.junit.Test)4 IndexedFile (org.sonar.api.batch.fs.IndexedFile)4 DefaultIndexedFile (org.sonar.api.batch.fs.internal.DefaultIndexedFile)4