@Test public void execute_command() { ScannerForMSBuild build = ScannerForMSBuild.create() .setProjectDir(new File(".")) .setProjectKey("SAMPLE") .setProjectName("Name") .setProjectVersion("1.1") .setTimeoutSeconds(30) .setDebugLogs(true) .setScannerVersion("2.2") .setEnvironmentVariable("FOO", "BAR"); Map<String, String> props = new TreeMap<>(); props.put("sonar.jdbc.dialect", "h2"); ScannerForMSBuildInstaller installer = mock(ScannerForMSBuildInstaller.class); when(installer.install(eq(Version.create("2.2")), eq(null), any(File.class), eq(false))).thenReturn(new File("SonarScanner.MSBuild.exe")); CommandExecutor executor = mock(CommandExecutor.class); when(executor.execute(any(Command.class), any(StreamConsumer.class), anyLong())).thenReturn(2); new ScannerForMSBuildExecutor().execute(build, Configuration.create(), props, installer, executor); verify(executor).execute(argThat(c -> c.getDirectory().equals(new File(".")) && c.toCommandLine().contains("SonarScanner.MSBuild.exe") && c.toCommandLine().contains("/d:sonar.verbose=true") && c.toCommandLine().contains("/k:SAMPLE") && c.toCommandLine().contains("/n:Name") && c.toCommandLine().contains("/v:1.1") && c.toCommandLine().contains("/d:sonar.jdbc.dialect=h2") && c.getEnvironmentVariables().get("FOO").equals("BAR")), any(StreamConsumer.class), eq(30000L)); }
@Override BuildResult execute(ScannerForMSBuild build, Configuration config, Map<String, String> adjustedProperties, CommandExecutor create) { return execute(build, config, adjustedProperties, new ScannerForMSBuildInstaller(config.locators()), create); }
ScannerForMSBuildExecutor extends AbstractBuildExecutor<ScannerForMSBuild> { @Override BuildResult execute(ScannerForMSBuild build, Configuration config, Map<String, String> adjustedProperties, CommandExecutor create) { return execute(build, config, adjustedProperties, new ScannerForMSBuildInstaller(config.locators()), create); } }
ScannerForMSBuildExecutor extends AbstractBuildExecutor<ScannerForMSBuild> { @Override BuildResult execute(ScannerForMSBuild build, Configuration config, Map<String, String> adjustedProperties, CommandExecutor create) { return execute(build, config, adjustedProperties, new ScannerForMSBuildInstaller(config.locators()), create); }  }
ScannerForMSBuildExecutor extends AbstractBuildExecutor<ScannerForMSBuild> { @Override BuildResult execute(ScannerForMSBuild build, Configuration config, Map<String, String> adjustedProperties, CommandExecutor create) { return execute(build, config, adjustedProperties, new ScannerForMSBuildInstaller(config.locators()), create); }  static void addProp(Command c, String key, String value); }
ScannerForMSBuildExecutor extends AbstractBuildExecutor<ScannerForMSBuild> { @Override BuildResult execute(ScannerForMSBuild build, Configuration config, Map<String, String> adjustedProperties, CommandExecutor create) { return execute(build, config, adjustedProperties, new ScannerForMSBuildInstaller(config.locators()), create); }  static void addProp(Command c, String key, String value);  }