aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-22 17:56:26 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-22 17:57:03 +0200
commitfa571d6a93e64229b4c5a4e068505eeaaa97079d (patch)
tree9b8f36613c81b53503af4cb3a58d5b0f515803db /sonar-batch
parent8d31b522cd2e15d0e6069773dd1adcedec21776c (diff)
downloadsonarqube-fa571d6a93e64229b4c5a4e068505eeaaa97079d.tar.gz
sonarqube-fa571d6a93e64229b4c5a4e068505eeaaa97079d.zip
Add medium test for InputDir
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java1
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java5
3 files changed, 12 insertions, 1 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
index ff60977901d..cde2d635f2e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
@@ -23,6 +23,7 @@ import org.apache.commons.io.IOUtils;
import org.sonar.api.SonarPlugin;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.batch.debt.internal.DefaultDebtModel;
+import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.batch.sensor.issue.Issue;
@@ -202,6 +203,7 @@ public class BatchMediumTester {
private List<Issue> issues = new ArrayList<Issue>();
private List<Measure> measures = new ArrayList<Measure>();
private List<InputFile> inputFiles = new ArrayList<InputFile>();
+ private List<InputDir> inputDirs = new ArrayList<InputDir>();
@Override
public void scanTaskCompleted(ProjectScanContainer container) {
@@ -217,6 +219,8 @@ public class BatchMediumTester {
for (InputPath inputPath : inputFileCache.all()) {
if (inputPath instanceof InputFile) {
inputFiles.add((InputFile) inputPath);
+ } else {
+ inputDirs.add((InputDir) inputPath);
}
}
}
@@ -233,6 +237,9 @@ public class BatchMediumTester {
return inputFiles;
}
+ public List<InputDir> inputDirs() {
+ return inputDirs;
+ }
}
private static class FakeGlobalReferentialsLoader implements GlobalReferentialsLoader {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
index afa3efd31c5..030febcd78d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
@@ -173,6 +173,7 @@ public class FileIndexer implements BatchComponent {
if (relativePath != null) {
DefaultInputDir inputDir = new DefaultInputDir(relativePath);
inputDir.setFile(parentDir);
+ inputDir.setKey(new StringBuilder().append(fs.moduleKey()).append(":").append(inputDir.relativePath()).toString());
status.markAsIndexed(inputDir);
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
index 90a6c1fcbea..ace6681869b 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
@@ -93,7 +93,10 @@ public class FileSystemMediumTest {
.start();
assertThat(result.inputFiles()).hasSize(1);
+ assertThat(result.inputDirs()).hasSize(1);
assertThat(result.inputFiles().get(0).type()).isEqualTo(InputFile.Type.MAIN);
+ assertThat(result.inputFiles().get(0).relativePath()).isEqualTo("src/sample.xoo");
+ assertThat(result.inputDirs().get(0).relativePath()).isEqualTo("src");
}
@Test
@@ -112,7 +115,7 @@ public class FileSystemMediumTest {
.start();
assertThat(result.inputFiles()).hasSize(1);
- // assertThat(result.inputPaths().get(0).type()).isEqualTo(InputFile.Type.TEST);
+ assertThat(result.inputFiles().get(0).type()).isEqualTo(InputFile.Type.TEST);
}
/**