Search in sources :

Example 96 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class LanguageDetectionTest method fail_if_conflicting_filepattern.

@Test
public void fail_if_conflicting_filepattern() throws Exception {
    LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("abap", "abap"), new MockLanguage("cobol", "cobol")));
    Settings settings = new MapSettings();
    settings.setProperty("sonar.lang.patterns.abap", "*.abap,*.txt");
    settings.setProperty("sonar.lang.patterns.cobol", "*.cobol,*.txt");
    LanguageDetection detection = new LanguageDetection(settings, languages);
    assertThat(detection.language(newIndexedFile("abc.abap"))).isEqualTo("abap");
    assertThat(detection.language(newIndexedFile("abc.cobol"))).isEqualTo("cobol");
    try {
        detection.language(newIndexedFile("abc.txt"));
        fail();
    } catch (MessageException e) {
        assertThat(e.getMessage()).contains("Language of file 'abc.txt' can not be decided as the file matches patterns of both ").contains("sonar.lang.patterns.abap : *.abap,*.txt").contains("sonar.lang.patterns.cobol : *.cobol,*.txt");
    }
}
Also used : MapSettings(org.sonar.api.config.MapSettings) MessageException(org.sonar.api.utils.MessageException) LanguagesRepository(org.sonar.scanner.repository.language.LanguagesRepository) DefaultLanguagesRepository(org.sonar.scanner.repository.language.DefaultLanguagesRepository) Languages(org.sonar.api.resources.Languages) DefaultLanguagesRepository(org.sonar.scanner.repository.language.DefaultLanguagesRepository) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 97 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class LanguageDetectionTest method should_not_fail_if_no_language.

@Test
public void should_not_fail_if_no_language() throws Exception {
    LanguageDetection detection = spy(new LanguageDetection(new MapSettings(), new DefaultLanguagesRepository(new Languages())));
    assertThat(detection.language(newIndexedFile("Foo.java"))).isNull();
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Languages(org.sonar.api.resources.Languages) DefaultLanguagesRepository(org.sonar.scanner.repository.language.DefaultLanguagesRepository) Test(org.junit.Test)

Example 98 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class ProjectReactorValidatorTest method prepare.

@Before
public void prepare() {
    mode = mock(DefaultAnalysisMode.class);
    settings = new MapSettings();
    validator = new ProjectReactorValidator(settings, mode);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) DefaultAnalysisMode(org.sonar.scanner.analysis.DefaultAnalysisMode) Before(org.junit.Before)

Aggregations

MapSettings (org.sonar.api.config.MapSettings)98 Test (org.junit.Test)75 Settings (org.sonar.api.config.Settings)36 Before (org.junit.Before)20 URI (java.net.URI)13 Languages (org.sonar.api.resources.Languages)9 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)9 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)8 File (java.io.File)7 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)7 FileExclusions (org.sonar.api.scan.filesystem.FileExclusions)6 Properties (java.util.Properties)5 IndexedFile (org.sonar.api.batch.fs.IndexedFile)5 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)5 DefaultIndexedFile (org.sonar.api.batch.fs.internal.DefaultIndexedFile)5 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)5 InputFile (org.sonar.api.batch.fs.InputFile)4 InputStream (java.io.InputStream)3 Description (org.hamcrest.Description)3 CoreProperties (org.sonar.api.CoreProperties)3