@BeforeEach
void mockBareMinimalServerEndpoints() {
sonarqube.stubFor(get("/api/plugins/installed")
- .willReturn(okJson("{\n"
- + " \"plugins\": []\n"
- + "}")));
+ .willReturn(okJson("""
+ {
+ "plugins": []
+ }
+ """)));
sonarqube.stubFor(get("/api/qualityprofiles/search.protobuf?project=" + PROJECT_KEY)
.willReturn(aResponse()
.build()))));
sonarqube.stubFor(get("/api/languages/list")
- .willReturn(okJson("{\n"
- + " \"languages\": []\n"
- + "}")));
+ .willReturn(okJson("""
+ {
+ "languages": []
+ }
+ """)));
sonarqube.stubFor(get("/api/metrics/search?ps=500&p=1")
- .willReturn(okJson("{\n"
- + " \"metrics\": [],\n"
- + " \"total\": 0,\n"
- + " \"p\": 1,\n"
- + " \"ps\": 100"
- + "}")));
+ .willReturn(okJson("""
+ {
+ "metrics": [],
+ "total": 0,
+ "p": 1,
+ "ps": 100
+ }
+ """)));
sonarqube.stubFor(post("/api/ce/submit?projectKey=" + PROJECT_KEY)
.willReturn(aResponse()
*/
package org.sonar.scanner.bootstrap;
-import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Files.delete(workingDir);
var tempFolder = underTest.provide(
- new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
+ new ScannerProperties(Map.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
tempFolder.newDir();
tempFolder.newFile();
}
underTest.provide(
- new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
+ new ScannerProperties(Map.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.toAbsolutePath().toString())), sonarUserHome);
// this also checks that all other temps were deleted
assertThat(workingDir.toFile().list()).hasSize(1);
}
@Test
- void createTempFolderFromSonarHome(@TempDir Path sonarUserHomePath) throws Exception {
+ void createTempFolderFromSonarHome(@TempDir Path sonarUserHomePath) {
// with sonar home, it will be in {sonar.home}/.sonartmp
when(sonarUserHome.getPath()).thenReturn(sonarUserHomePath);
when(sonarUserHome.getPath()).thenReturn(sonarUserHomePath);
String globalWorkDir = ".";
ScannerProperties globalProperties = new ScannerProperties(
- ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, globalWorkDir));
+ Map.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, globalWorkDir));
var tempFolder = underTest.provide(globalProperties, sonarUserHome);
File newFile = tempFolder.newFile();
private static final GlobalAnalysisMode GLOBAL_ANALYSIS_MODE = new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap()));
private static final AnalysisWarnings ANALYSIS_WARNINGS = warning -> {
};
- @TempDir
- private Path sonarUserHomeDir;
- private final SonarUserHome sonarUserHome = mock(SonarUserHome.class);
+ private SonarUserHome sonarUserHome = mock(SonarUserHome.class);
private final Map<String, String> scannerProps = new HashMap<>();
private final ScannerWsClientProvider underTest = new ScannerWsClientProvider();
private final Properties systemProps = new Properties();
@BeforeEach
- void configureMocks() {
+ void configureMocks(@TempDir Path sonarUserHomeDir) {
when(system2.properties()).thenReturn(systemProps);
- when(sonarUserHome.getPath()).thenReturn(sonarUserHomeDir);
+ sonarUserHome = new SonarUserHome(sonarUserHomeDir);
}
@Test