aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-03-03 10:11:03 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-03-03 10:11:03 +0100
commita637ef0b0081bf758e3b19950a5de6d794425b46 (patch)
tree26be7923c14299d4272264ffa156db82673e4246 /sonar-scanner-engine
parent2d898468dc31c97922f1757a308bb891bece4140 (diff)
downloadsonarqube-a637ef0b0081bf758e3b19950a5de6d794425b46.tar.gz
sonarqube-a637ef0b0081bf758e3b19950a5de6d794425b46.zip
Fix JSONReportTest
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
index 59ce9e71958..7dfcdc7d367 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
@@ -28,8 +28,10 @@ import java.util.Collections;
import java.util.TimeZone;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputDir;
@@ -44,6 +46,7 @@ import org.sonar.api.config.Settings;
import org.sonar.api.issue.Issue;
import org.sonar.api.platform.Server;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.scanner.issue.IssueCache;
import org.sonar.scanner.issue.tracking.TrackedIssue;
import org.sonar.scanner.protocol.input.ScannerInput;
@@ -61,7 +64,7 @@ public class JSONReportTest {
private SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
- @org.junit.Rule
+ @Rule
public TemporaryFolder temp = new TemporaryFolder();
JSONReport jsonReport;
@@ -77,25 +80,29 @@ public class JSONReportTest {
public void before() throws Exception {
moduleHierarchy = mock(InputModuleHierarchy.class);
userRepository = mock(UserRepositoryLoader.class);
- fs = new DefaultFileSystem(temp.newFolder().toPath());
+ File projectBaseDir = temp.newFolder();
+ fs = new DefaultFileSystem(projectBaseDir.toPath());
SIMPLE_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+02:00"));
when(server.getVersion()).thenReturn("3.6");
- DefaultInputDir inputDir = new DefaultInputDir("struts", "src/main/java/org/apache/struts", TestInputFileBuilder.nextBatchId());
- DefaultInputFile inputFile = new TestInputFileBuilder("struts", "src/main/java/org/apache/struts/Action.java").build();
- inputFile.setStatus(InputFile.Status.CHANGED);
- inputFile.setPublish(true);
- InputComponentStore fileCache = new InputComponentStore();
- fileCache.put(inputFile);
- fileCache.put(inputDir);
-
+ InputComponentStore inputComponentStore = new InputComponentStore(new PathResolver());
DefaultComponentTree inputComponentTree = new DefaultComponentTree();
- DefaultInputModule rootModule = new DefaultInputModule("struts");
+ DefaultInputModule rootModule = new DefaultInputModule(ProjectDefinition.create().setBaseDir(projectBaseDir).setKey("struts"), 1);
+ inputComponentStore.put(rootModule);
DefaultInputModule moduleA = new DefaultInputModule("struts-core");
inputComponentTree.index(moduleA, rootModule);
DefaultInputModule moduleB = new DefaultInputModule("struts-ui");
inputComponentTree.index(moduleB, rootModule);
+ DefaultInputDir inputDir = new DefaultInputDir("struts", "src/main/java/org/apache/struts", TestInputFileBuilder.nextBatchId())
+ .setModuleBaseDir(projectBaseDir.toPath());
+ DefaultInputFile inputFile = new TestInputFileBuilder("struts", "src/main/java/org/apache/struts/Action.java")
+ .setModuleBaseDir(projectBaseDir.toPath()).build();
+ inputFile.setStatus(InputFile.Status.CHANGED);
+ inputFile.setPublish(true);
+ inputComponentStore.put(inputFile);
+ inputComponentStore.put(inputDir);
+
inputComponentTree.index(inputDir, rootModule);
inputComponentTree.index(inputFile, inputDir);
@@ -108,7 +115,7 @@ public class JSONReportTest {
RulesBuilder builder = new RulesBuilder();
builder.add(RuleKey.of("squid", "AvoidCycles")).setName("Avoid Cycles");
rules = builder.build();
- jsonReport = new JSONReport(moduleHierarchy, settings, fs, server, rules, issueCache, rootModule, fileCache, userRepository, inputComponentTree);
+ jsonReport = new JSONReport(moduleHierarchy, settings, fs, server, rules, issueCache, rootModule, inputComponentStore, userRepository, inputComponentTree);
}
@Test