Java Code Examples for org.sonar.api.config.Settings#setProperty()

The following examples show how to use org.sonar.api.config.Settings#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CssLanguageTest.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void custom_file_suffixes() {
  Settings settings = new Settings();
  settings.setProperty("sonar.css.file.suffixes", "css,css3");

  CssLanguage language = new CssLanguage(settings);
  assertThat(language.getFileSuffixes()).containsOnly("css", "css3");
}
 
Example 2
Source File: LessLanguageTest.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void custom_file_suffixes() {
  Settings settings = new Settings();
  settings.setProperty("sonar.less.file.suffixes", "less,less3");

  LessLanguage language = new LessLanguage(settings);
  assertThat(language.getFileSuffixes()).containsOnly("less", "less3");
}
 
Example 3
Source File: ScssLanguageTest.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void custom_file_suffixes() {
  Settings settings = new Settings();
  settings.setProperty("sonar.scss.file.suffixes", "scss,scss3");

  ScssLanguage language = new ScssLanguage(settings);
  assertThat(language.getFileSuffixes()).containsOnly("scss", "scss3");
}
 
Example 4
Source File: RubyTest.java    From sonar-ruby-plugin with MIT License 5 votes vote down vote up
@Test
public void testGetFileSuffixes_Override() {
    Settings settings = new Settings();
    settings.setProperty("sonar.ruby.file.suffixes", "rb");

    Ruby ruby = new Ruby(settings);

    String[] fileSuffixes = ruby.getFileSuffixes();

    assertThat(fileSuffixes).hasSize(1);
    assertThat(fileSuffixes).hasSameElementsAs(Lists.newArrayList("rb"));
}
 
Example 5
Source File: RubyTest.java    From sonar-ruby-plugin with MIT License 5 votes vote down vote up
@Test
public void testGetFileSuffixes_WithSpaces() {
    Settings settings = new Settings();
    settings.setProperty("sonar.ruby.file.suffixes", "rb, , gemspec");

    Ruby ruby = new Ruby(settings);

    String[] fileSuffixes = ruby.getFileSuffixes();

    assertThat(fileSuffixes).hasSize(2);
    assertThat(fileSuffixes).hasSameElementsAs(Lists.newArrayList("rb", "gemspec"));
}
 
Example 6
Source File: TSQLLanguageTest.java    From sonar-tsql-plugin with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDefinedSuffixes() {
	final Settings settings = new org.sonar.api.config.internal.MapSettings();
	settings.setProperty(Constants.PLUGIN_SUFFIXES, ".sql,.test");
	final TSQLLanguage language = new TSQLLanguage(settings);
	Assert.assertArrayEquals(new String[] { ".sql", ".test" }, language.getFileSuffixes());
}
 
Example 7
Source File: TsLintExecutorConfigTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void fromSettings_setsTimeoutTo5000msMinimum_ifSetToLess() {
    Settings settings = new Settings();
    settings.setProperty(TypeScriptPlugin.SETTING_TS_LINT_TIMEOUT, 1000);

    PathResolver resolver = mock(PathResolver.class);

    TsLintExecutorConfig config = TsLintExecutorConfig.fromSettings(settings, SensorContextTester.create(new File("")), resolver);

    assertEquals((Integer) 5000, config.getTimeoutMs());
}
 
Example 8
Source File: LuaTest.java    From sonar-lua with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testGetFileSuffixes() {
  Settings settings = new Settings();
 Lua lua = new Lua(settings);

  assertThat(lua.getFileSuffixes()).isEqualTo(new String[] {"lua"});

  settings.setProperty(LuaPlugin.FILE_SUFFIXES_KEY, "");
  assertThat(lua.getFileSuffixes()).isEqualTo(new String[] {"lua"});

  settings.setProperty(LuaPlugin.FILE_SUFFIXES_KEY, "lua");
  assertThat(lua.getFileSuffixes()).isEqualTo(new String[] {"lua"});
}
 
Example 9
Source File: TsLintExecutorConfigTest.java    From SonarTsPlugin with MIT License 4 votes vote down vote up
@Test
public void fromSettings_initialisesFromSettingsAndResolver() {
    Settings settings = new Settings();
    settings.setProperty(TypeScriptPlugin.SETTING_TS_LINT_TIMEOUT, 12000);
    settings.setProperty(TypeScriptPlugin.SETTING_TS_LINT_TYPECHECK, true);

    PathResolver resolver = mock(PathResolver.class);

    when(resolver.getPath(any(SensorContext.class),
                           eq(TypeScriptPlugin.SETTING_TS_LINT_PATH),
                           eq(TsLintExecutorConfig.TSLINT_FALLBACK_PATH))
    ).thenReturn("tslint");

    when(resolver.getPath(any(SensorContext.class),
                           eq(TypeScriptPlugin.SETTING_TS_LINT_CONFIG_PATH),
                           eq(TsLintExecutorConfig.CONFIG_FILENAME))
    ).thenReturn("tslint.json");

    when(resolver.getPath(any(SensorContext.class),
                           eq(TypeScriptPlugin.SETTING_TS_LINT_RULES_DIR),
                           eq((String) null))
    ).thenReturn("rulesdir");

    when(resolver.getPath(any(SensorContext.class),
                           eq(TypeScriptPlugin.SETTING_TS_LINT_PROJECT_PATH),
                           eq((String) null))
    ).thenReturn("tsconfig.json");

    when(resolver.getPath(any(SensorContext.class),
                            eq(TypeScriptPlugin.SETTING_TS_LINT_OUTPUT_PATH),
                            eq((String) null))
    ).thenReturn("out.json");

    TsLintExecutorConfig config = TsLintExecutorConfig.fromSettings(settings, SensorContextTester.create(new File("")), resolver);

    assertEquals("tslint", config.getPathToTsLint());
    assertEquals("tslint.json", config.getConfigFile());
    assertEquals("rulesdir", config.getRulesDir());
    assertEquals("tsconfig.json", config.getPathToTsConfig());

    assertEquals("out.json", config.getPathToTsLintOutput());
    assertTrue(config.shouldPerformTypeCheck());
    assertEquals((Integer) 12000, config.getTimeoutMs());
}