diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-26 10:22:10 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-26 10:22:10 +0200 |
commit | 4234c8d5b402e751dfd0c17732cfc843ba807fe0 (patch) | |
tree | b4fd81647c26834baae2d8f2457b85472d89602f /sonar-batch-protocol/src | |
parent | 966878dbed44b73db1e5951056f9ee2bc617d652 (diff) | |
download | sonarqube-4234c8d5b402e751dfd0c17732cfc843ba807fe0.tar.gz sonarqube-4234c8d5b402e751dfd0c17732cfc843ba807fe0.zip |
Revert "SONAR-5473 Fix fetching of remote SCM data"
This reverts commit da96eeccbe28e91619d60b34ae91ad442de6ce08.
Diffstat (limited to 'sonar-batch-protocol/src')
2 files changed, 13 insertions, 23 deletions
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 d967e933de4..5e2bfafd59d 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, Map<String, FileData>> fileDataByModuleAndPath = new HashMap<String, Map<String, FileData>>(); + private Map<String, FileData> fileDataPerPath = new HashMap<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,23 +73,13 @@ public class ProjectReferentials { return this; } - 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; + public Map<String, FileData> fileDataPerPath() { + return fileDataPerPath; } @CheckForNull - public FileData fileData(String projectKey, String path) { - return fileDataByPath(projectKey).get(path); + public FileData fileDataPerPath(String path) { + return fileDataPerPath.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 5e537a1f523..ed98c51e46b 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.addFileData("foo", "src/main/java/Foo.java", new FileData("xyz", "1=12345,2=3456", "1=345,2=345", "1=henryju,2=gaudin")); + ref.fileDataPerPath().put("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}}," - + "fileDataByModuleAndPath:{foo:{\"src/main/java/Foo.java\":{hash:xyz,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}}", + + "fileDataPerPath:{\"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}}," - + "fileDataByModuleAndPath:{foo:{\"src/main/java/Foo.java\":{hash:xyz,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}}"); + + "fileDataPerPath:{\"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.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"); + 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"); } } |