org.sonar.api.config.internal.MapSettings Java Examples
The following examples show how to use
org.sonar.api.config.internal.MapSettings.
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: CheckstyleConfigurationTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void getTargetXmlReport() { final org.sonar.api.config.Configuration settings = new ConfigurationBridge(new MapSettings()); final CheckstyleConfiguration configuration = new CheckstyleConfiguration(settings, null, null, fileSystem); assertThat(configuration.getTargetXmlReport()).isNull(); final MapSettings mapSettings = new MapSettings(); mapSettings.setProperty(CheckstyleConfiguration.PROPERTY_GENERATE_XML, "true"); final org.sonar.api.config.Configuration settings2 = new ConfigurationBridge(mapSettings); final CheckstyleConfiguration configuration2 = new CheckstyleConfiguration(settings2, null, null, fileSystem); assertThat(configuration2.getTargetXmlReport()).isEqualTo( new File(fileSystem.workDir(), "checkstyle-result.xml")); }
Example #2
Source File: MessageUtilsTest.java From sonar-gerrit-plugin with Apache License 2.0 | 6 votes |
@Test public void validateIssueSubstitution() { // given PostJobIssue issue = mock(PostJobIssue.class); when(issue.isNew()).thenReturn(true); when(issue.ruleKey()).thenReturn(RuleKey.of("squid", "XX12")); when(issue.message()).thenReturn("You have a problem there"); when(issue.severity()).thenReturn(Severity.BLOCKER); // when MapSettings settings = new MapSettings(); settings.setProperty(PropertyKey.GERRIT_ISSUE_COMMENT, "[${issue.isNew}] New: ${issue.ruleKey} on ${sonar.host.url} Severity: ${issue.severity}, Message: ${issue.message}") .setProperty("sonar.host.url", "http://sq.example.com/"); // then assertThat(MessageUtils.createIssueMessage(settings.getString(PropertyKey.GERRIT_ISSUE_COMMENT), settings, issue)).isEqualTo( "[true] New: squid:XX12 on http://sq.example.com/ Severity: BLOCKER, Message: You have a problem there"); }
Example #3
Source File: GerritPostJobTest.java From sonar-gerrit-plugin with Apache License 2.0 | 6 votes |
@BeforeEach public void setUp() { ReviewHolder.getReviewInput().emptyComments(); // Common Settings settings = new MapSettings(); settings.setProperty(PropertyKey.GERRIT_SCHEME, GerritConstants.SCHEME_HTTP) .setProperty(PropertyKey.GERRIT_HOST, "localhost") .appendProperty(PropertyKey.GERRIT_PORT, "10800") .setProperty(PropertyKey.GERRIT_PROJECT, "project") .setProperty(PropertyKey.GERRIT_CHANGE_ID, "changeid") .setProperty(PropertyKey.GERRIT_REVISION_ID, "revisionid") .setProperty(PropertyKey.GERRIT_VOTE_NO_ISSUE, "1") .setProperty(PropertyKey.GERRIT_VOTE_ISSUE_ABOVE_THRESHOLD, "-2") .setProperty(PropertyKey.GERRIT_VOTE_ISSUE_BELOW_THRESHOLD, "-1") .setProperty(PropertyKey.GERRIT_ENABLED, "true") .setProperty(PropertyKey.GERRIT_MESSAGE, "Message Test") .setProperty(PropertyKey.GERRIT_ISSUE_COMMENT, "[New: ${issue.isNew}] ${issue.severity}(${issue.ruleKey}) found: ${issue.message}") .setProperty(PropertyKey.GERRIT_LABEL, LABEL); }
Example #4
Source File: CloverSensorTest.java From sonar-clover with Apache License 2.0 | 6 votes |
@Test public void should_process_file() throws Exception { final String cloverFilePath = "org/sonar/plugins/clover/CloverXmlReportParserTest/clover_2_6_0.xml"; final File cloverFile = TestUtils.getResource(cloverFilePath); final MapSettings settings = new MapSettings(); settings.setProperty(CloverSensor.REPORT_PATH_PROPERTY, cloverFile.getAbsolutePath()); final DefaultFileSystem fs = context.fileSystem(); fs.add(new TestInputFileBuilder("", cloverFile.getAbsolutePath()).build()); final Configuration configuration = new ConfigurationBridge(settings); final CloverSensor sensor = new CloverSensor(configuration, fs, new PathResolver()); sensor.execute(context); assertThat(logTester.logs(LoggerLevel.INFO)).contains("Parsing " + cloverFile.getCanonicalPath()); assertThat(logTester.logs(LoggerLevel.WARN).stream().anyMatch(s -> s.contains("14 files in Clover report did not match any file in SonarQube Index"))).isEqualTo(true); }
Example #5
Source File: TraceSensorTest.java From sonar-esql-plugin with Apache License 2.0 | 6 votes |
@Before public void init() throws FileNotFoundException { settings = new MapSettings(); settings.setProperty("sonar.esql.trace.reportPaths", "TraceSensorTest/trace.txt"); context = SensorContextTester.create(moduleBaseDir); context.setSettings(settings); InputFile inputFile1 = inputFile("file1.esql", Type.MAIN); InputFile inputFile2 = inputFile("file2.esql", Type.MAIN); InputFile inputFile3 = inputFile("file3.esql", Type.MAIN); // inputFile("tests/file1.esql", Type.TEST); linesOfCode = new HashMap<>(); linesOfCode.put(inputFile1, ImmutableSet.of(1, 2, 3, 4)); linesOfCode.put(inputFile2, null); linesOfCode.put(inputFile3, ImmutableSet.of(1, 2, 3, 4)); sensor = new TraceSensor(); }
Example #6
Source File: CrowdConfigurationTest.java From sonar-crowd with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void createsClientProperties() { MapSettings settings = new MapSettings(); settings.setProperty(CrowdConfiguration.KEY_CROWD_URL, "http://localhost:8095"); settings.setProperty(CrowdConfiguration.KEY_CROWD_APP_NAME, "SonarQube"); settings.setProperty(CrowdConfiguration.KEY_CROWD_APP_PASSWORD, "secret"); CrowdConfiguration crowdConfiguration = new CrowdConfiguration(settings.asConfig()); assertThat(crowdConfiguration.getCrowdUrl(), is("http://localhost:8095")); assertThat(crowdConfiguration.getCrowdApplicationName(), is("SonarQube")); assertThat(crowdConfiguration.getCrowdApplicationPassword(), is("secret")); }
Example #7
Source File: CrowdConfigurationTest.java From sonar-crowd with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void usesFallbackForUnsetApplicationName() { MapSettings settings = new MapSettings(); settings.setProperty(CrowdConfiguration.KEY_CROWD_URL, "http://localhost:8095"); settings.setProperty(CrowdConfiguration.KEY_CROWD_APP_PASSWORD, "secret"); CrowdConfiguration crowdConfiguration = new CrowdConfiguration(settings.asConfig()); assertThat(crowdConfiguration.getCrowdApplicationName(), is(CrowdConfiguration.FALLBACK_NAME)); }
Example #8
Source File: GerritConfigurationTest.java From sonar-gerrit-plugin with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() { MapSettings settings = new MapSettings(); settings.setProperty(PropertyKey.GERRIT_SCHEME, SCHEME).setProperty(PropertyKey.GERRIT_HOST, HOST) .setProperty(PropertyKey.GERRIT_PORT, PORT.toString()).setProperty(PropertyKey.GERRIT_USERNAME, USERNAME) .setProperty(PropertyKey.GERRIT_PASSWORD, PASSWORD).setProperty(PropertyKey.GERRIT_BASE_PATH, "") .setProperty(PropertyKey.GERRIT_PROJECT, PROJECT).setProperty(PropertyKey.GERRIT_BRANCH, BRANCH) .setProperty(PropertyKey.GERRIT_CHANGE_ID, CHANGE_ID) .setProperty(PropertyKey.GERRIT_REVISION_ID, REVISION_ID) .setProperty(PropertyKey.GERRIT_LABEL, LABEL); gerritConfiguration = new GerritConfiguration(settings); }
Example #9
Source File: MessageUtilsTest.java From sonar-gerrit-plugin with Apache License 2.0 | 5 votes |
@Test public void validateSubstitution() { // given MapSettings settings = new MapSettings(); settings.setProperty(PropertyKey.GERRIT_MESSAGE, "Sonar review at ${sonar.host.url}") .setProperty("sonar.host.url", "http://sq.example.com/"); // then assertThat(MessageUtils.createMessage(settings.getString(PropertyKey.GERRIT_MESSAGE), settings)) .isEqualTo("Sonar review at http://sq.example.com/"); }
Example #10
Source File: GerritRestConnectorTest.java From sonar-gerrit-plugin with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() { // Common Settings settings = new MapSettings(); settings.setProperty(PropertyKey.GERRIT_SCHEME, GerritConstants.SCHEME_HTTP) .setProperty(PropertyKey.GERRIT_HOST, "localhost") .appendProperty(PropertyKey.GERRIT_PORT, "10800") .setProperty(PropertyKey.GERRIT_PROJECT, "project") .setProperty(PropertyKey.GERRIT_CHANGE_ID, "changeid") .setProperty(PropertyKey.GERRIT_REVISION_ID, "revisionid") .setProperty(PropertyKey.GERRIT_LABEL, "Code-Review"); }
Example #11
Source File: CloverSensorTest.java From sonar-clover with Apache License 2.0 | 5 votes |
@Test public void should_not_interact_if_no_report_path() { final MapSettings settings = new MapSettings(); settings.setProperty(CloverSensor.REPORT_PATH_PROPERTY, ""); final Configuration configuration = new ConfigurationBridge(settings); final CloverSensor sensor = new CloverSensor(configuration, context.fileSystem(), new PathResolver()); sensor.execute(context); assertThat(logTester.logs(LoggerLevel.WARN)).contains( CloverSensor.MISSING_FILE_MESSAGE); }
Example #12
Source File: CloverSensorTest.java From sonar-clover with Apache License 2.0 | 5 votes |
@Test public void should_describe() { final DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor(); final CloverSensor sensor = new CloverSensor(new ConfigurationBridge(new MapSettings()), context.fileSystem(), new PathResolver()); sensor.describe(descriptor); assertThat(descriptor.name()).isNotNull(); assertThat(descriptor.languages()).hasSize(2); }
Example #13
Source File: TestUtils.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
private static EsqlVisitorContext createContext(InputFile file, ActionParser<Tree> parser) { try { ProgramTree programTree = (ProgramTree) parser.parse(file.contents()); return new EsqlVisitorContext(programTree, file, new MapSettings().asConfig()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #14
Source File: EsqlExclusionsFileFilterTest.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
@Test public void should_ignore_empty_path_regex() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty(EsqlPlugin.ESQL_EXCLUSIONS_KEY, "," + EsqlPlugin.ESQL_EXCLUSIONS_DEFAULT_VALUE + ","); EsqlExclusionsFileFilter filter = new EsqlExclusionsFileFilter(settings.asConfig()); assertThat(filter.accept(inputFile("some_app.esql"))).isTrue(); }
Example #15
Source File: EsqlExclusionsFileFilterTest.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
@Test public void should_exclude_using_custom_path_regex() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty( EsqlPlugin.ESQL_EXCLUSIONS_KEY, EsqlPlugin.ESQL_EXCLUSIONS_DEFAULT_VALUE + "," + "**/libs/**"); EsqlExclusionsFileFilter filter = new EsqlExclusionsFileFilter(settings.asConfig()); assertThat(filter.accept(inputFile("some_app.esql"))).isTrue(); assertThat(filter.accept(inputFile("libs/some_lib.esql"))).isFalse(); }
Example #16
Source File: EsqlLanguageTest.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
@Test public void customSuffixes() { MapSettings mapSettings = new MapSettings(); mapSettings.setProperty(EsqlLanguage.FILE_SUFFIXES_KEY, "esql"); EsqlLanguage esqlLanguage = new EsqlLanguage(mapSettings.asConfig()); assertThat(esqlLanguage.getFileSuffixes()).containsOnly("esql"); }
Example #17
Source File: EsqlLanguageTest.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
@Test public void defaultSuffixes() { MapSettings mapSettings = new MapSettings(); mapSettings.setProperty(EsqlLanguage.FILE_SUFFIXES_KEY, EsqlLanguage.FILE_SUFFIXES_DEFVALUE); EsqlLanguage esqlLanguage = new EsqlLanguage(mapSettings.asConfig()); assertThat(esqlLanguage.getFileSuffixes()).containsOnly(".esql"); }
Example #18
Source File: TestUtils.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
public static EsqlVisitorContext createContext(InputFile file) { try { EsqlTree programTree = (EsqlTree) EsqlParserBuilder.createParser().parse(file.contents()); return new EsqlVisitorContext((ProgramTree)programTree, file, new MapSettings().asConfig()); } catch (IOException e) { throw Throwables.propagate(e); } }
Example #19
Source File: CheckstyleConfigurationTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void getCheckstyleConfiguration() throws Exception { fileSystem.setEncoding(StandardCharsets.UTF_8); final MapSettings mapSettings = new MapSettings(new PropertyDefinitions( new CheckstylePlugin().getExtensions())); mapSettings.setProperty(CheckstyleConstants.CHECKER_FILTERS_KEY, CheckstyleConstants.CHECKER_FILTERS_DEFAULT_VALUE); final org.sonar.api.config.Configuration settings = new ConfigurationBridge(mapSettings); final RulesProfile profile = RulesProfile.create("sonar way", "java"); final Rule rule = Rule.create("checkstyle", "CheckStyleRule1", "checkstyle rule one"); rule.setConfigKey("checkstyle/rule1"); profile.activateRule(rule, null); final CheckstyleConfiguration configuration = new CheckstyleConfiguration(settings, new CheckstyleProfileExporter(settings), new DefaultActiveRules(Collections.emptyList()), fileSystem); final Configuration checkstyleConfiguration = configuration.getCheckstyleConfiguration(); assertThat(checkstyleConfiguration).isNotNull(); assertThat(checkstyleConfiguration.getAttribute("charset")).isEqualTo("UTF-8"); final File xmlFile = new File("checkstyle.xml"); assertThat(xmlFile.exists()).isTrue(); FileUtils.forceDelete(xmlFile); }
Example #20
Source File: CheckstyleProfileExporterTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") private void initSettings(@Nullable String key, @Nullable String property) { final MapSettings mapSettings = new MapSettings( new PropertyDefinitions(new CheckstylePlugin().getExtensions())); if (Objects.nonNull(key)) { mapSettings.setProperty(key, property); } settings = new ConfigurationBridge(mapSettings); }
Example #21
Source File: EsqlLanguageTest.java From sonar-esql-plugin with Apache License 2.0 | 4 votes |
@Before public void setUp() { settings = new MapSettings(); esqlLanguage = new EsqlLanguage(settings.asConfig()); }
Example #22
Source File: CheckstyleConfigurationTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 4 votes |
FakeExporter() { super(new ConfigurationBridge(new MapSettings())); }
Example #23
Source File: CrowdConfigurationTest.java From sonar-crowd with GNU Lesser General Public License v3.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void crowdUrlMissing() { MapSettings settings = new MapSettings(); new CrowdConfiguration(settings.asConfig()).getCrowdUrl(); }
Example #24
Source File: CrowdConfigurationTest.java From sonar-crowd with GNU Lesser General Public License v3.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void applicationPasswordMissing() { MapSettings settings = new MapSettings(); settings.setProperty(CrowdConfiguration.KEY_CROWD_URL, "http://localhost:8095"); new CrowdConfiguration(settings.asConfig()).getCrowdApplicationPassword(); }
Example #25
Source File: ClojureTest.java From sonar-clojure with MIT License | 4 votes |
@Before public void setUp() { settings = new MapSettings(); language = new Clojure(settings.asConfig()); }