aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-07-20 17:38:19 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-08-07 11:44:06 +0200
commitc69324daaf2b08efa2fdc68d01c2fff105b34cdf (patch)
tree337723a33e7592e252463e2c08ec367a176f119d /sonar-scanner-engine/src/test/java
parentdd380b60b61eb5de47051a746d0141b8250e5560 (diff)
downloadsonarqube-c69324daaf2b08efa2fdc68d01c2fff105b34cdf.tar.gz
sonarqube-c69324daaf2b08efa2fdc68d01c2fff105b34cdf.zip
SONAR-9576 Add analysis mode in the scanner report
Diffstat (limited to 'sonar-scanner-engine/src/test/java')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java21
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java6
2 files changed, 10 insertions, 17 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
index ea3ffc3737d..8d679016b61 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
@@ -19,11 +19,12 @@
*/
package org.sonar.scanner.mediumtest.tasks;
-import com.google.common.collect.ImmutableMap;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.util.Arrays;
import java.util.List;
+
import org.assertj.core.api.Condition;
-import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -32,10 +33,9 @@ import org.sonar.api.task.Task;
import org.sonar.api.task.TaskDefinition;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.log.LogTester;
-import org.sonar.scanner.bootstrap.MockHttpServer;
import org.sonar.scanner.mediumtest.ScannerMediumTester;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.google.common.collect.ImmutableMap;
public class TasksMediumTest {
@@ -49,15 +49,6 @@ public class TasksMediumTest {
public ScannerMediumTester tester = new ScannerMediumTester()
.registerPlugin("faketask", new FakeTaskPlugin());
- private MockHttpServer server = null;
-
- @After
- public void stopServer() {
- if (server != null) {
- server.stop();
- }
- }
-
@Test
public void listTasksIncludingBroken() throws Exception {
tester.newTask()
@@ -96,8 +87,6 @@ public class TasksMediumTest {
@Test
public void incrementalNotFound() throws Exception {
- tester.start();
-
thrown.expect(MessageException.class);
thrown.expectMessage(
"Incremental mode is not available. Please contact your administrator.");
@@ -105,7 +94,7 @@ public class TasksMediumTest {
tester.newTask()
.properties(ImmutableMap.<String, String>builder()
.put("sonar.incremental", "true").build())
- .start();
+ .execute();
}
private static class FakeTaskPlugin extends SonarPlugin {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
index b804fd08df2..fbe8a44cf43 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
@@ -27,6 +27,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
@@ -58,6 +59,7 @@ public class MetadataPublisherTest {
private ProjectAnalysisInfo projectAnalysisInfo;
private CpdSettings cpdSettings;
private InputModuleHierarchy inputModuleHierarchy;
+ private AnalysisMode analysisMode;
@Before
public void prepare() throws IOException {
@@ -73,7 +75,8 @@ public class MetadataPublisherTest {
rootModule = new DefaultInputModule(def.setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder()), TestInputFileBuilder.nextBatchId());
inputModuleHierarchy = mock(InputModuleHierarchy.class);
when(inputModuleHierarchy.root()).thenReturn(rootModule);
- underTest = new MetadataPublisher(projectAnalysisInfo, inputModuleHierarchy, settings.asConfig(), qProfiles, cpdSettings);
+ analysisMode = mock(AnalysisMode.class);
+ underTest = new MetadataPublisher(projectAnalysisInfo, inputModuleHierarchy, settings.asConfig(), qProfiles, cpdSettings, analysisMode);
}
@Test
@@ -91,6 +94,7 @@ public class MetadataPublisherTest {
assertThat(metadata.getAnalysisDate()).isEqualTo(1234567L);
assertThat(metadata.getProjectKey()).isEqualTo("foo");
assertThat(metadata.getProjectKey()).isEqualTo("foo");
+ assertThat(metadata.getIncremental()).isFalse();
assertThat(metadata.getQprofilesPerLanguage()).containsOnly(entry("java", org.sonar.scanner.protocol.output.ScannerReport.Metadata.QProfile.newBuilder()
.setKey("q1")
.setName("Q1")