@Test public void testMavenFormat() { assertThat(new LoggingConfiguration(new EnvironmentInformation("maven", "1.0")) .getSubstitutionVariable(LoggingConfiguration.PROPERTY_FORMAT)).isEqualTo(LoggingConfiguration.FORMAT_MAVEN); }
@Test public void test_bean() { EnvironmentInformation env = new EnvironmentInformation("Maven Plugin", "2.0"); assertThat(env.getKey()).isEqualTo("Maven Plugin"); assertThat(env.getVersion()).isEqualTo("2.0"); }
@Test public void test_toString() { EnvironmentInformation env = new EnvironmentInformation("Maven Plugin", "2.0"); assertThat(env.toString()).isEqualTo("Maven Plugin/2.0"); } }
public LoggingConfiguration(@Nullable EnvironmentInformation environment) { setVerbose(false); if (environment != null && "maven".equalsIgnoreCase(environment.getKey())) { setFormat(FORMAT_MAVEN); } else { setFormat(FORMAT_DEFAULT); } }
public ServerClient(BootstrapProperties settings, EnvironmentInformation env) { this.props = settings; this.downloader = new HttpDownloader.BaseHttpDownloader(settings.properties(), env.toString()); }
private boolean isRunnerVersionLessThan2Dot4() { EnvironmentInformation env = this.getComponentByType(EnvironmentInformation.class); // Starting from SQ Runner 2.4 the key is "SonarQubeRunner" return env != null && "SonarRunner".equals(env.getKey()); }
public void setUp(boolean verbose) { Batch.Builder builder = Batch.builder() .setEnableLoggingConfiguration(true) .addComponents( loader, new EnvironmentInformation("mediumTest", "1.0")); if (verbose) { builder.setBootstrapProperties(Collections.singletonMap("sonar.verbose", "true")); } batch = builder.build(); }
public static boolean supportsEnvironment(Object extension, EnvironmentInformation environment) { SupportedEnvironment env = AnnotationUtils.getAnnotation(extension, SupportedEnvironment.class); if (env == null) { return true; } for (String supported : env.value()) { if (StringUtils.equalsIgnoreCase(environment.getKey(), supported)) { return true; } } return false; }
private Batch newBatch() { return Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .build(); }
private LoggingConfiguration(@Nullable EnvironmentInformation environment) { setVerbose(false); if (environment != null && "maven".equalsIgnoreCase(environment.getKey())) { setFormat(FORMAT_MAVEN); } else { setFormat(FORMAT_DEFAULT); } }
@Test(expected = IllegalStateException.class) public void shouldFailIfNullComponents() { Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .setComponents(null) .build(); }
public LoggingConfiguration(@Nullable EnvironmentInformation environment) { setVerbose(false); if (environment != null && "maven".equalsIgnoreCase(environment.getKey())) { setFormat(FORMAT_MAVEN); } else { setFormat(FORMAT_DEFAULT); } }
public AnalysisResult execute() { AnalysisResult result = new AnalysisResult(); Map<String, String> props = new HashMap<>(); props.putAll(tester.globalProperties); props.putAll(taskProperties); Batch.builder() .setGlobalProperties(props) .setEnableLoggingConfiguration(true) .addComponents(new EnvironmentInformation("mediumTest", "1.0"), tester.pluginInstaller, tester.globalRefProvider, tester.qualityProfiles, tester.rulesLoader, tester.branchConfigurationLoader, tester.projectRefProvider, tester.activeRules, tester.serverIssues, tester.settingsLoader, result) .setLogOutput(tester.logOutput) .build().execute(); return result; }
public LoggingConfiguration(@Nullable EnvironmentInformation environment) { setVerbose(false); if (environment != null && "maven".equalsIgnoreCase(environment.getKey())) { setFormat(FORMAT_MAVEN); } else { setFormat(FORMAT_DEFAULT); } }
@Test public void shouldDisableLoggingConfiguration() { Batch batch = Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .setEnableLoggingConfiguration(false) .build(); assertNull(batch.getLoggingConfiguration()); }
Batch createBatch(String sonarVersion, Properties properties, List<Object> extensions) { initLogging(properties); EnvironmentInformation env = new EnvironmentInformation(properties.getProperty("sonarRunner.app"), properties.getProperty("sonarRunner.appVersion")); return Batch.builder() .setEnvironment(env) .addComponents(extensions) .setBootstrapProperties((Map) properties) .build(); }
@Override public Batch createBatch(Map<String, String> properties, final org.sonarsource.scanner.api.internal.batch.LogOutput logOutput) { EnvironmentInformation env = new EnvironmentInformation(properties.get(SCANNER_APP_KEY), properties.get(SCANNER_APP_VERSION_KEY)); return Batch.builder() .setEnvironment(env) .setGlobalProperties(properties) .setLogOutput((formattedMessage, level) -> logOutput.log(formattedMessage, LogOutput.Level.valueOf(level.name()))) .build(); } }
@Override public Batch createBatch(Map<String, String> properties, final org.sonarsource.scanner.api.internal.batch.LogOutput logOutput) { EnvironmentInformation env = new EnvironmentInformation(properties.get(SCANNER_APP_KEY), properties.get(SCANNER_APP_VERSION_KEY)); return Batch.builder() .setEnvironment(env) .setGlobalProperties(properties) .setLogOutput((formattedMessage, level) -> logOutput.log(formattedMessage, LogOutput.Level.valueOf(level.name()))) .build(); } }
@Override public Batch createBatch(Properties properties, @Nullable final org.sonar.runner.batch.LogOutput logOutput, @Nullable List<Object> extensions) { EnvironmentInformation env = new EnvironmentInformation(properties.getProperty("sonarRunner.app"), properties.getProperty("sonarRunner.appVersion")); Batch.Builder builder = Batch.builder() .setEnvironment(env) .setBootstrapProperties((Map) properties); if (extensions != null) { builder.addComponents(extensions); } if (logOutput != null) { // Do that is a separate class to avoid NoClassDefFoundError for org/sonar/batch/bootstrapper/LogOutput Compatibility.setLogOutputFor5dot2(builder, logOutput); } return builder.build(); } }
private BatchMediumTester(BatchMediumTesterBuilder builder) { batch = Batch.builder() .setEnableLoggingConfiguration(true) .addComponents( new EnvironmentInformation("mediumTest", "1.0"), builder.pluginsReferential, builder.globalRefProvider, builder.projectRefProvider, builder.serverIssues, builder.serverLineHashes, new DefaultDebtModel()) .setBootstrapProperties(builder.bootstrapProperties) .build(); }