use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class ExclusionFiltersTest method no_inclusions_nor_exclusions.
@Test
public void no_inclusions_nor_exclusions() throws IOException {
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(new MapSettings()));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDao.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
assertThat(filter.accept(indexedFile, InputFile.Type.TEST)).isTrue();
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class ExclusionFiltersTest method match_at_least_one_inclusion.
@Test
public void match_at_least_one_inclusion() throws IOException {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Dao.java,**/*Dto.java");
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/Foo.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isFalse();
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDto.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class ExclusionFiltersTest method match_exclusions.
@Test
public void match_exclusions() throws IOException {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "src/main/java/**/*");
settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "src/test/java/**/*");
settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*Dao.java");
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDao.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isFalse();
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/Foo.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
// source exclusions do not apply to tests
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/test/java/com/mycompany/FooDao.java");
assertThat(filter.accept(indexedFile, InputFile.Type.TEST)).isTrue();
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class ExclusionFiltersTest method match_exclusion_by_absolute_path.
@Test
public void match_exclusion_by_absolute_path() throws IOException {
File excludedFile = new File(moduleBaseDir.toString(), "src/main/java/org/bar/Bar.java");
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "src/main/java/**/*");
settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "file:" + excludedFile.getAbsolutePath());
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/org/bar/Foo.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/org/bar/Bar.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isFalse();
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class InputFileBuilderTest method setUp.
@Before
public void setUp() throws IOException {
baseDir = temp.newFolder().toPath();
DefaultInputModule module = new DefaultInputModule(ProjectDefinition.create().setKey("module1").setBaseDir(baseDir.toFile()), 0);
PathResolver pathResolver = new PathResolver();
LanguageDetection langDetection = mock(LanguageDetection.class);
MetadataGenerator metadataGenerator = mock(MetadataGenerator.class);
BatchIdGenerator idGenerator = new BatchIdGenerator();
Settings settings = new MapSettings();
builder = new InputFileBuilder(module, pathResolver, langDetection, metadataGenerator, idGenerator, settings);
}
Aggregations