aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-09-25 16:23:37 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-09-25 16:25:24 +0200
commitda96eeccbe28e91619d60b34ae91ad442de6ce08 (patch)
tree71ba7b694981fadcf92e4ec9ef8aaf43b3504c81
parenta4e76de07797ea2b9b809a0cc0b90286c90cd3cd (diff)
downloadsonarqube-da96eeccbe28e91619d60b34ae91ad442de6ce08.tar.gz
sonarqube-da96eeccbe28e91619d60b34ae91ad442de6ce08.zip
SONAR-5473 Fix fetching of remote SCM data
-rw-r--r--plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java5
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java5
-rw-r--r--pom.xml6
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json3
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json3
-rw-r--r--sonar-application/pom.xml6
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java22
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java14
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java37
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java119
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetection.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scm/ScmActivitySensor.java8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/referential/DefaultProjectReferentialsLoaderTest.java10
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/StatusDetectionTest.java10
30 files changed, 184 insertions, 118 deletions
diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java
index 0d8b447cdd8..a8c56b7ab9c 100644
--- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java
+++ b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java
@@ -21,6 +21,8 @@ package org.sonar.plugins.scm.git;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.scm.BlameCommand;
@@ -30,7 +32,8 @@ import org.sonar.api.utils.command.StreamConsumer;
import java.io.File;
-public class GitBlameCommand implements BlameCommand {
+@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
+public class GitBlameCommand implements BlameCommand, BatchComponent {
private static final Logger LOG = LoggerFactory.getLogger(GitBlameCommand.class);
private final CommandExecutor commandExecutor;
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java
index 7d492cc315b..4e743613788 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java
@@ -23,6 +23,8 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
+import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.scm.BlameCommand;
@@ -35,7 +37,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-public class XooBlameCommand implements BlameCommand {
+@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
+public class XooBlameCommand implements BlameCommand, BatchComponent {
private static final String SCM_EXTENSION = ".scm";
diff --git a/pom.xml b/pom.xml
index 7ed75fe5291..411ddbd06f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -587,6 +587,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.codehaus.sonar.plugins</groupId>
+ <artifactId>sonar-git-plugin</artifactId>
+ <version>${project.version}</version>
+ <type>sonar-plugin</type>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-squid</artifactId>
<version>4.1</version>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json
index 8037eff7213..cf8408bc74c 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json
@@ -13,5 +13,6 @@
"org.codehaus.sonar:sonar": {
"sonar.jira.project.key": "SONAR"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json
index f7f8faf299b..7662ed047f6 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json
@@ -21,5 +21,6 @@
}
}
],
- "settingsByModule": {}
+ "settingsByModule": {},
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json
index 4b562891c28..9d2a070ffc5 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json
@@ -14,5 +14,6 @@
"sonar.jira.project.key": "SONAR",
"sonar.jira.login.secured": "john"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json
index d1b864aa7c4..705186dc248 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json
@@ -19,5 +19,6 @@
"sonar.jira.login.secured": "john",
"sonar.coverage.exclusions": "**/*.java"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json
index deaea79e1a3..ad8a65322b7 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json
@@ -18,5 +18,6 @@
"sonar.jira.project.key": "SONAR",
"sonar.jira.login.secured": "john"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json
index ef8ef13fa12..12b74d0cb7c 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json
@@ -24,5 +24,6 @@
"sonar.jira.login.secured": "john",
"sonar.coverage.exclusions": "**/*.java"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json
index 302176c60f1..c0816864ed6 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json
@@ -23,5 +23,6 @@
"sonar.jira.project.key": "SONAR-APPLICATION",
"sonar.jira.login.secured": "john"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json
index 282fafa5b33..2031cd6b1f0 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json
@@ -9,5 +9,6 @@
}
},
"activeRules": [],
- "settingsByModule": {}
+ "settingsByModule": {},
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json
index a1bb33bb01f..e9c873bb519 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json
@@ -9,5 +9,6 @@
}
},
"activeRules": [],
- "settingsByModule": {}
+ "settingsByModule": {},
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json
index a1bb33bb01f..e9c873bb519 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json
@@ -9,5 +9,6 @@
}
},
"activeRules": [],
- "settingsByModule": {}
+ "settingsByModule": {},
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json
index 282fafa5b33..2031cd6b1f0 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json
@@ -9,5 +9,6 @@
}
},
"activeRules": [],
- "settingsByModule": {}
+ "settingsByModule": {},
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json
index a1bb33bb01f..e9c873bb519 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json
@@ -9,5 +9,6 @@
}
},
"activeRules": [],
- "settingsByModule": {}
+ "settingsByModule": {},
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json
index f2a89a9895a..87515800786 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json
@@ -15,5 +15,6 @@
"sonar.jira.login.secured": "john",
"sonar.coverage.exclusions": "**/*.java"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json
index f2a89a9895a..87515800786 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json
@@ -15,5 +15,6 @@
"sonar.jira.login.secured": "john",
"sonar.coverage.exclusions": "**/*.java"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json
index f2a89a9895a..87515800786 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json
@@ -15,5 +15,6 @@
"sonar.jira.login.secured": "john",
"sonar.coverage.exclusions": "**/*.java"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json
index c99fd8e67db..5accba5c7e7 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json
@@ -15,5 +15,6 @@
"sonar.jira.login.secured": "john",
"sonar.coverage.exclusions": "**/*.java"
}
- }
+ },
+ "fileDataPerPath": {}
}
diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml
index fda2e82eba3..547bff09e2d 100644
--- a/sonar-application/pom.xml
+++ b/sonar-application/pom.xml
@@ -132,6 +132,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.codehaus.sonar.plugins</groupId>
+ <artifactId>sonar-git-plugin</artifactId>
+ <type>sonar-plugin</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.sonatype.jsw-binaries</groupId>
<artifactId>jsw-binaries</artifactId>
<version>3.2.3.6</version>
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java
index 5e2bfafd59d..d967e933de4 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java
@@ -39,7 +39,7 @@ public class ProjectReferentials {
private Map<String, QProfile> qprofilesByLanguage = new HashMap<String, QProfile>();
private Collection<ActiveRule> activeRules = new ArrayList<ActiveRule>();
private Map<String, Map<String, String>> settingsByModule = new HashMap<String, Map<String, String>>();
- private Map<String, FileData> fileDataPerPath = new HashMap<String, FileData>();
+ private Map<String, Map<String, FileData>> fileDataByModuleAndPath = new HashMap<String, Map<String, FileData>>();
public Map<String, String> settings(String projectKey) {
return settingsByModule.containsKey(projectKey) ? settingsByModule.get(projectKey) : Collections.<String, String>emptyMap();
@@ -49,9 +49,9 @@ public class ProjectReferentials {
Map<String, String> existingSettings = settingsByModule.get(projectKey);
if (existingSettings == null) {
existingSettings = new HashMap<String, String>();
+ settingsByModule.put(projectKey, existingSettings);
}
existingSettings.putAll(settings);
- settingsByModule.put(projectKey, existingSettings);
return this;
}
@@ -73,13 +73,23 @@ public class ProjectReferentials {
return this;
}
- public Map<String, FileData> fileDataPerPath() {
- return fileDataPerPath;
+ public Map<String, FileData> fileDataByPath(String projectKey) {
+ return fileDataByModuleAndPath.containsKey(projectKey) ? fileDataByModuleAndPath.get(projectKey) : Collections.<String, FileData>emptyMap();
+ }
+
+ public ProjectReferentials addFileData(String projectKey, String path, FileData fileData) {
+ Map<String, FileData> existingFileDataByPath = fileDataByModuleAndPath.get(projectKey);
+ if (existingFileDataByPath == null) {
+ existingFileDataByPath = new HashMap<String, FileData>();
+ fileDataByModuleAndPath.put(projectKey, existingFileDataByPath);
+ }
+ existingFileDataByPath.put(path, fileData);
+ return this;
}
@CheckForNull
- public FileData fileDataPerPath(String path) {
- return fileDataPerPath.get(path);
+ public FileData fileData(String projectKey, String path) {
+ return fileDataByPath(projectKey).get(path);
}
public long timestamp() {
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
index ed98c51e46b..5e537a1f523 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
@@ -49,7 +49,7 @@ public class ProjectReferentialsTest {
activeRule.addParam("param1", "value1");
ref.addActiveRule(activeRule);
ref.setTimestamp(10);
- ref.fileDataPerPath().put("src/main/java/Foo.java", new FileData("xyz", "1=12345,2=3456", "1=345,2=345", "1=henryju,2=gaudin"));
+ ref.addFileData("foo", "src/main/java/Foo.java", new FileData("xyz", "1=12345,2=3456", "1=345,2=345", "1=henryju,2=gaudin"));
System.out.println(ref.toJson());
JSONAssert
@@ -58,7 +58,7 @@ public class ProjectReferentialsTest {
+ "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"Mar 14, 1984 12:00:00 AM\"}},"
+ "activeRules:[{repositoryKey:repo,ruleKey:rule,name:Rule,severity:MAJOR,internalKey:rule,language:java,params:{param1:value1}}],"
+ "settingsByModule:{foo:{prop1:value1,prop2:value2,prop:value}},"
- + "fileDataPerPath:{\"src/main/java/Foo.java\":{hash:xyz,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}",
+ + "fileDataByModuleAndPath:{foo:{\"src/main/java/Foo.java\":{hash:xyz,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}}",
ref.toJson(), true);
}
@@ -69,7 +69,7 @@ public class ProjectReferentialsTest {
+ "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"Mar 14, 1984 12:00:00 AM\"}},"
+ "activeRules:[{repositoryKey:repo,ruleKey:rule,name:Rule,severity:MAJOR,internalKey:rule1,language:java,params:{param1:value1}}],"
+ "settingsByModule:{foo:{prop:value}},"
- + "fileDataPerPath:{\"src/main/java/Foo.java\":{hash:xyz,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}");
+ + "fileDataByModuleAndPath:{foo:{\"src/main/java/Foo.java\":{hash:xyz,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}}");
assertThat(ref.timestamp()).isEqualTo(1);
@@ -88,9 +88,9 @@ public class ProjectReferentialsTest {
assertThat(qProfile.rulesUpdatedAt()).isEqualTo(new SimpleDateFormat("dd/MM/yyyy").parse("14/03/1984"));
assertThat(ref.settings("foo")).includes(MapAssert.entry("prop", "value"));
- assertThat(ref.fileDataPerPath("src/main/java/Foo.java").hash()).isEqualTo("xyz");
- assertThat(ref.fileDataPerPath("src/main/java/Foo.java").scmAuthorsByLine()).isEqualTo("1=henryju,2=gaudin");
- assertThat(ref.fileDataPerPath("src/main/java/Foo.java").scmLastCommitDatetimesByLine()).isEqualTo("1=12345,2=3456");
- assertThat(ref.fileDataPerPath("src/main/java/Foo.java").scmRevisionsByLine()).isEqualTo("1=345,2=345");
+ assertThat(ref.fileData("foo", "src/main/java/Foo.java").hash()).isEqualTo("xyz");
+ assertThat(ref.fileData("foo", "src/main/java/Foo.java").scmAuthorsByLine()).isEqualTo("1=henryju,2=gaudin");
+ assertThat(ref.fileData("foo", "src/main/java/Foo.java").scmLastCommitDatetimesByLine()).isEqualTo("1=12345,2=3456");
+ assertThat(ref.fileData("foo", "src/main/java/Foo.java").scmRevisionsByLine()).isEqualTo("1=345,2=345");
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
index 40df91b4ab4..565417efad0 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
@@ -25,7 +25,6 @@ import org.sonar.api.batch.TimeMachine;
import org.sonar.api.batch.TimeMachineQuery;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.MeasureModel;
-import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
@@ -39,7 +38,6 @@ import org.sonar.batch.index.DefaultIndex;
import javax.annotation.Nullable;
import javax.persistence.Query;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -150,41 +148,6 @@ public class DefaultTimeMachine implements TimeMachine {
return jpaQuery.getResultList();
}
- // Temporary implementation for SONAR-5473
- public List<MeasureModel> query(String resourceKey, Integer... metricIds) {
- StringBuilder sb = new StringBuilder();
- Map<String, Object> params = Maps.newHashMap();
-
- sb.append("SELECT m");
- sb.append(" FROM ")
- .append(MeasureModel.class.getSimpleName())
- .append(" m, ")
- .append(ResourceModel.class.getSimpleName())
- .append(" r, ")
- .append(Snapshot.class.getSimpleName())
- .append(" s WHERE m.snapshotId=s.id AND s.resourceId=r.id AND r.kee=:kee AND s.status=:status AND s.qualifier<>:lib");
- params.put("kee", resourceKey);
- params.put("status", Snapshot.STATUS_PROCESSED);
- params.put("lib", Qualifiers.LIBRARY);
-
- sb.append(" AND m.characteristicId IS NULL");
- sb.append(" AND m.personId IS NULL");
- sb.append(" AND m.ruleId IS NULL AND m.rulePriority IS NULL");
- if (metricIds.length > 0) {
- sb.append(" AND m.metricId IN (:metricIds) ");
- params.put("metricIds", Arrays.asList(metricIds));
- }
- sb.append(" AND s.last=true ");
- sb.append(" ORDER BY s.createdAt ");
-
- Query jpaQuery = session.createQuery(sb.toString());
-
- for (Map.Entry<String, Object> entry : params.entrySet()) {
- jpaQuery.setParameter(entry.getKey(), entry.getValue());
- }
- return jpaQuery.getResultList();
- }
-
public Map<Integer, Metric> getMetricsById(TimeMachineQuery query) {
Collection<Metric> metrics = metricFinder.findAll(query.getMetricKeys());
Map<Integer, Metric> result = Maps.newHashMap();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java b/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
index 98c46ef1172..d3a85a912a9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
@@ -20,22 +20,33 @@
package org.sonar.batch.referential;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.MeasureModel;
+import org.sonar.api.database.model.ResourceModel;
+import org.sonar.api.database.model.Snapshot;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.MetricFinder;
-import org.sonar.batch.DefaultTimeMachine;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.utils.KeyValueFormat;
import org.sonar.batch.bootstrap.AnalysisMode;
import org.sonar.batch.bootstrap.ServerClient;
import org.sonar.batch.bootstrap.TaskProperties;
import org.sonar.batch.protocol.input.FileData;
import org.sonar.batch.protocol.input.ProjectReferentials;
import org.sonar.batch.rule.ModuleQProfiles;
-import org.sonar.batch.scan.filesystem.PreviousFileHashLoader;
+import org.sonar.core.source.SnapshotDataTypes;
+import org.sonar.core.source.db.SnapshotDataDao;
+import org.sonar.core.source.db.SnapshotDataDto;
+
+import javax.persistence.Query;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -50,17 +61,15 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
private final ServerClient serverClient;
private final AnalysisMode analysisMode;
- private final PreviousFileHashLoader fileHashLoader;
- private final MetricFinder metricFinder;
- private final DefaultTimeMachine defaultTimeMachine;
+ private final SnapshotDataDao dao;
+ private final DatabaseSession session;
- public DefaultProjectReferentialsLoader(ServerClient serverClient, AnalysisMode analysisMode, PreviousFileHashLoader fileHashLoader, MetricFinder finder,
- DefaultTimeMachine defaultTimeMachine) {
+ public DefaultProjectReferentialsLoader(DatabaseSession session, ServerClient serverClient, AnalysisMode analysisMode,
+ SnapshotDataDao dao) {
+ this.session = session;
this.serverClient = serverClient;
this.analysisMode = analysisMode;
- this.fileHashLoader = fileHashLoader;
- this.metricFinder = finder;
- this.defaultTimeMachine = defaultTimeMachine;
+ this.dao = dao;
}
@Override
@@ -77,28 +86,78 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
url += "&preview=" + analysisMode.isPreview();
ProjectReferentials ref = ProjectReferentials.fromJson(serverClient.request(url));
- Integer lastCommitsId = metricFinder.findByKey(CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE.key()).getId();
- Integer revisionsId = metricFinder.findByKey(CoreMetrics.SCM_REVISIONS_BY_LINE.key()).getId();
- Integer authorsId = metricFinder.findByKey(CoreMetrics.SCM_AUTHORS_BY_LINE.key()).getId();
- for (Map.Entry<String, String> hashByPaths : fileHashLoader.hashByRelativePath().entrySet()) {
- String path = hashByPaths.getKey();
- String hash = hashByPaths.getValue();
- String lastCommits = null;
- String revisions = null;
- String authors = null;
- List<MeasureModel> measures = defaultTimeMachine.query(projectKey + ":" + path, lastCommitsId, revisionsId, authorsId);
- for (MeasureModel m : measures) {
- if (m.getMetricId() == lastCommitsId) {
- lastCommits = m.getData(CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE);
- } else if (m.getMetricId() == revisionsId) {
- revisions = m.getData(CoreMetrics.SCM_REVISIONS_BY_LINE);
- }
- if (m.getMetricId() == authorsId) {
- authors = m.getData(CoreMetrics.SCM_AUTHORS_BY_LINE);
+ for (ProjectDefinition module : reactor.getProjects()) {
+
+ for (Map.Entry<String, String> hashByPaths : hashByRelativePath(module.getKeyWithBranch()).entrySet()) {
+ String path = hashByPaths.getKey();
+ String hash = hashByPaths.getValue();
+ String lastCommits = null;
+ String revisions = null;
+ String authors = null;
+ List<Object[]> measuresByKey = query(projectKey + ":" + path, CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, CoreMetrics.SCM_REVISIONS_BY_LINE_KEY,
+ CoreMetrics.SCM_AUTHORS_BY_LINE_KEY);
+ for (Object[] measureByKey : measuresByKey) {
+ if (measureByKey[0].equals(CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY)) {
+ lastCommits = ((MeasureModel) measureByKey[1]).getData(CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE);
+ } else if (measureByKey[0].equals(CoreMetrics.SCM_REVISIONS_BY_LINE_KEY)) {
+ revisions = ((MeasureModel) measureByKey[1]).getData(CoreMetrics.SCM_REVISIONS_BY_LINE);
+ } else if (measureByKey[0].equals(CoreMetrics.SCM_AUTHORS_BY_LINE_KEY)) {
+ authors = ((MeasureModel) measureByKey[1]).getData(CoreMetrics.SCM_AUTHORS_BY_LINE);
+ }
}
+ ref.addFileData(projectKey, path, new FileData(hash, lastCommits, revisions, authors));
}
- ref.fileDataPerPath().put(path, new FileData(hash, lastCommits, revisions, authors));
}
return ref;
}
+
+ public Map<String, String> hashByRelativePath(String projectKey) {
+ Map<String, String> map = Maps.newHashMap();
+ Collection<SnapshotDataDto> selectSnapshotData = dao.selectSnapshotDataByComponentKey(
+ projectKey,
+ Arrays.asList(SnapshotDataTypes.FILE_HASHES)
+ );
+ if (!selectSnapshotData.isEmpty()) {
+ SnapshotDataDto snapshotDataDto = selectSnapshotData.iterator().next();
+ String data = snapshotDataDto.getData();
+ map = KeyValueFormat.parse(data);
+ }
+ return map;
+ }
+
+ public List<Object[]> query(String resourceKey, String... metricKeys) {
+ StringBuilder sb = new StringBuilder();
+ Map<String, Object> params = Maps.newHashMap();
+
+ sb.append("SELECT met.key, m");
+ sb.append(" FROM ")
+ .append(MeasureModel.class.getSimpleName())
+ .append(" m, ")
+ .append(Metric.class.getSimpleName())
+ .append(" met, ")
+ .append(ResourceModel.class.getSimpleName())
+ .append(" r, ")
+ .append(Snapshot.class.getSimpleName())
+ .append(" s WHERE met.id=m.metricId AND m.snapshotId=s.id AND s.resourceId=r.id AND r.key=:kee AND s.status=:status AND s.qualifier<>:lib");
+ params.put("kee", resourceKey);
+ params.put("status", Snapshot.STATUS_PROCESSED);
+ params.put("lib", Qualifiers.LIBRARY);
+
+ sb.append(" AND m.characteristicId IS NULL");
+ sb.append(" AND m.personId IS NULL");
+ sb.append(" AND m.ruleId IS NULL AND m.rulePriority IS NULL");
+ if (metricKeys.length > 0) {
+ sb.append(" AND met.key IN (:metricKeys) ");
+ params.put("metricKeys", Arrays.asList(metricKeys));
+ }
+ sb.append(" AND s.last=true ");
+ sb.append(" ORDER BY s.createdAt ");
+
+ Query jpaQuery = session.createQuery(sb.toString());
+
+ for (Map.Entry<String, Object> entry : params.entrySet()) {
+ jpaQuery.setParameter(entry.getKey(), entry.getValue());
+ }
+ return jpaQuery.getResultList();
+ }
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java
index 4e8ed7eedc9..cc099ba9f9c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java
@@ -98,7 +98,7 @@ class InputFileBuilder {
FileMetadata.Metadata metadata = FileMetadata.INSTANCE.read(inputFile.file(), fs.encoding());
inputFile.setLines(metadata.lines);
inputFile.setHash(metadata.hash);
- inputFile.setStatus(statusDetection.status(inputFile.relativePath(), metadata.hash));
+ inputFile.setStatus(statusDetection.status(inputFile.moduleKey(), inputFile.relativePath(), metadata.hash));
if (analysisMode.isIncremental() && inputFile.status() == InputFile.Status.SAME) {
return null;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetection.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetection.java
index 96840779d22..8843e604989 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetection.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetection.java
@@ -32,8 +32,8 @@ class StatusDetection {
this.projectReferentials = projectReferentials;
}
- InputFile.Status status(String relativePath, String hash) {
- FileData fileDataPerPath = projectReferentials.fileDataPerPath(relativePath);
+ InputFile.Status status(String projectKey, String relativePath, String hash) {
+ FileData fileDataPerPath = projectReferentials.fileData(projectKey, relativePath);
if (fileDataPerPath == null) {
return InputFile.Status.ADDED;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmActivitySensor.java b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmActivitySensor.java
index 350135a0780..ba7a1fe0ee7 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmActivitySensor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmActivitySensor.java
@@ -21,6 +21,7 @@ package org.sonar.batch.scm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFile.Status;
@@ -51,11 +52,14 @@ public final class ScmActivitySensor implements Sensor {
private static final Pattern NON_ASCII_CHARS = Pattern.compile("[^\\x00-\\x7F]");
private static final Pattern ACCENT_CODES = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
+ private final ProjectDefinition projectDefinition;
private final ScmActivityConfiguration configuration;
private final FileSystem fs;
private final ProjectReferentials projectReferentials;
- public ScmActivitySensor(ScmActivityConfiguration configuration, ProjectReferentials projectReferentials, FileSystem fs) {
+ public ScmActivitySensor(ProjectDefinition projectDefinition, ScmActivityConfiguration configuration,
+ ProjectReferentials projectReferentials, FileSystem fs) {
+ this.projectDefinition = projectDefinition;
this.configuration = configuration;
this.projectReferentials = projectReferentials;
this.fs = fs;
@@ -81,7 +85,7 @@ public final class ScmActivitySensor implements Sensor {
List<InputFile> filesToBlame = new LinkedList<InputFile>();
for (InputFile f : fs.inputFiles(fs.predicates().all())) {
- FileData fileData = projectReferentials.fileDataPerPath(f.relativePath());
+ FileData fileData = projectReferentials.fileData(projectDefinition.getKeyWithBranch(), f.relativePath());
if (f.status() == Status.SAME
&& fileData != null
&& fileData.scmAuthorsByLine() != null
diff --git a/sonar-batch/src/test/java/org/sonar/batch/referential/DefaultProjectReferentialsLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/referential/DefaultProjectReferentialsLoaderTest.java
index 95821910b74..d190df314c1 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/referential/DefaultProjectReferentialsLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/referential/DefaultProjectReferentialsLoaderTest.java
@@ -24,14 +24,12 @@ import org.junit.Before;
import org.junit.Test;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.MetricFinder;
-import org.sonar.batch.DefaultTimeMachine;
+import org.sonar.api.database.DatabaseSession;
import org.sonar.batch.bootstrap.AnalysisMode;
import org.sonar.batch.bootstrap.ServerClient;
import org.sonar.batch.bootstrap.TaskProperties;
import org.sonar.batch.rule.ModuleQProfiles;
-import org.sonar.batch.scan.filesystem.PreviousFileHashLoader;
+import org.sonar.core.source.db.SnapshotDataDao;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
@@ -50,9 +48,7 @@ public class DefaultProjectReferentialsLoaderTest {
public void prepare() {
serverClient = mock(ServerClient.class);
analysisMode = mock(AnalysisMode.class);
- MetricFinder metricFinder = mock(MetricFinder.class);
- when(metricFinder.findByKey(anyString())).thenReturn(new Metric().setId(1));
- loader = new DefaultProjectReferentialsLoader(serverClient, analysisMode, mock(PreviousFileHashLoader.class), metricFinder, mock(DefaultTimeMachine.class));
+ loader = new DefaultProjectReferentialsLoader(mock(DatabaseSession.class), serverClient, analysisMode, mock(SnapshotDataDao.class));
when(serverClient.request(anyString())).thenReturn("");
reactor = new ProjectReactor(ProjectDefinition.create().setKey("foo"));
taskProperties = new TaskProperties(Maps.<String, String>newHashMap(), "");
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
index 067f1f99d58..91fcbfa0c78 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
@@ -62,7 +62,7 @@ public class InputFileBuilderTest {
when(langDetection.language(any(InputFile.class))).thenReturn("java");
// status
- when(statusDetection.status("src/main/java/foo/Bar.java", "6c1d64c0b3555892fe7273e954f6fb5a"))
+ when(statusDetection.status("foo", "src/main/java/foo/Bar.java", "6c1d64c0b3555892fe7273e954f6fb5a"))
.thenReturn(InputFile.Status.ADDED);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
@@ -135,7 +135,7 @@ public class InputFileBuilderTest {
when(langDetection.language(any(InputFile.class))).thenReturn("java");
// status
- when(statusDetection.status("src/main/java/foo/Bar.java", "6c1d64c0b3555892fe7273e954f6fb5a"))
+ when(statusDetection.status("foo", "src/main/java/foo/Bar.java", "6c1d64c0b3555892fe7273e954f6fb5a"))
.thenReturn(InputFile.Status.ADDED);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
@@ -164,7 +164,7 @@ public class InputFileBuilderTest {
when(langDetection.language(any(InputFile.class))).thenReturn("php");
// status
- when(statusDetection.status("src/Bar.php", "6c1d64c0b3555892fe7273e954f6fb5a"))
+ when(statusDetection.status("foo", "src/Bar.php", "6c1d64c0b3555892fe7273e954f6fb5a"))
.thenReturn(InputFile.Status.ADDED);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/StatusDetectionTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/StatusDetectionTest.java
index ecadbe3b1be..e40df46c172 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/StatusDetectionTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/StatusDetectionTest.java
@@ -30,12 +30,12 @@ public class StatusDetectionTest {
@Test
public void detect_status() throws Exception {
ProjectReferentials ref = new ProjectReferentials();
- ref.fileDataPerPath().put("src/Foo.java", new FileData("ABCDE", null, null, null));
- ref.fileDataPerPath().put("src/Bar.java", new FileData("FGHIJ", null, null, null));
+ ref.addFileData("foo", "src/Foo.java", new FileData("ABCDE", null, null, null));
+ ref.addFileData("foo", "src/Bar.java", new FileData("FGHIJ", null, null, null));
StatusDetection statusDetection = new StatusDetection(ref);
- assertThat(statusDetection.status("src/Foo.java", "ABCDE")).isEqualTo(InputFile.Status.SAME);
- assertThat(statusDetection.status("src/Foo.java", "XXXXX")).isEqualTo(InputFile.Status.CHANGED);
- assertThat(statusDetection.status("src/Other.java", "QWERT")).isEqualTo(InputFile.Status.ADDED);
+ assertThat(statusDetection.status("foo", "src/Foo.java", "ABCDE")).isEqualTo(InputFile.Status.SAME);
+ assertThat(statusDetection.status("foo", "src/Foo.java", "XXXXX")).isEqualTo(InputFile.Status.CHANGED);
+ assertThat(statusDetection.status("foo", "src/Other.java", "QWERT")).isEqualTo(InputFile.Status.ADDED);
}
}