@@ -57,9 +57,11 @@ class BootstrapMediumIT { | |||
@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() | |||
@@ -77,17 +79,21 @@ class BootstrapMediumIT { | |||
.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() |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.scanner.bootstrap; | |||
import com.google.common.collect.ImmutableMap; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.nio.file.Files; | |||
@@ -49,7 +48,7 @@ class GlobalTempFolderProviderTest { | |||
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(); | |||
@@ -71,7 +70,7 @@ class GlobalTempFolderProviderTest { | |||
} | |||
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); | |||
@@ -88,7 +87,7 @@ class GlobalTempFolderProviderTest { | |||
} | |||
@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); | |||
@@ -109,7 +108,7 @@ class GlobalTempFolderProviderTest { | |||
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(); |
@@ -78,7 +78,7 @@ class PluginFilesTest { | |||
private PluginFiles underTest; | |||
@BeforeEach | |||
void setUp(@TempDir Path sonarUserHomeDir) throws Exception { | |||
void setUp(@TempDir Path sonarUserHomeDir) { | |||
when(sonarUserHome.getPath()).thenReturn(sonarUserHomeDir); | |||
HttpConnector connector = HttpConnector.newBuilder().acceptGzip(true).url(sonarqube.url("/")).build(); |
@@ -66,9 +66,7 @@ class ScannerWsClientProviderTest { | |||
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(); | |||
@@ -78,9 +76,9 @@ class ScannerWsClientProviderTest { | |||
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 |