diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-02-09 11:41:55 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-02-09 11:56:57 +0100 |
commit | 5053107fc465f952e63d42308ee621023db855e8 (patch) | |
tree | 7277d69ba4b52d1618cb5305067a674c64596af2 /sonar-batch-protocol | |
parent | 0ea7c0cedcadefe53e5ea7aab1e66592c0cb9279 (diff) | |
download | sonarqube-5053107fc465f952e63d42308ee621023db855e8.tar.gz sonarqube-5053107fc465f952e63d42308ee621023db855e8.zip |
SONAR-6162 Return template rule key in /batch/projects WS
Diffstat (limited to 'sonar-batch-protocol')
-rw-r--r-- | sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java | 11 | ||||
-rw-r--r-- | sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoriesTest.java | 7 |
2 files changed, 13 insertions, 5 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java index d9bf2e3bea7..ab6e6c64192 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java @@ -26,13 +26,15 @@ import java.util.HashMap; import java.util.Map; public class ActiveRule { - private final String repositoryKey, ruleKey; + private final String repositoryKey, ruleKey, templateRuleKey; private final String name, severity, internalKey, language; private final Map<String, String> params = new HashMap<String, String>(); - public ActiveRule(String repositoryKey, String ruleKey, String name, @Nullable String severity, @Nullable String internalKey, @Nullable String language) { + public ActiveRule(String repositoryKey, String ruleKey, @Nullable String templateRuleKey, String name, @Nullable String severity, + @Nullable String internalKey, @Nullable String language) { this.repositoryKey = repositoryKey; this.ruleKey = ruleKey; + this.templateRuleKey = templateRuleKey; this.name = name; this.severity = severity; this.internalKey = internalKey; @@ -47,6 +49,11 @@ public class ActiveRule { return ruleKey; } + @CheckForNull + public String templateRuleKey() { + return templateRuleKey; + } + public String name() { return name; } diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoriesTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoriesTest.java index e4eb540d291..cfb584f97e7 100644 --- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoriesTest.java +++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoriesTest.java @@ -44,7 +44,7 @@ public class ProjectRepositoriesTest { settings.put("prop2", "value2"); ref.addSettings("foo", settings); ref.settings("foo").put("prop", "value"); - ActiveRule activeRule = new ActiveRule("repo", "rule", "Rule", "MAJOR", "rule", "java"); + ActiveRule activeRule = new ActiveRule("repo", "rule", "templateRule", "Rule", "MAJOR", "rule", "java"); activeRule.addParam("param1", "value1"); ref.addActiveRule(activeRule); ref.setLastAnalysisDate(new SimpleDateFormat("dd/MM/yyyy").parse("31/10/2014")); @@ -56,7 +56,7 @@ public class ProjectRepositoriesTest { .assertEquals( "{timestamp:10," + "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"1984-03-14T00:00:00+0100\"}}," - + "activeRules:[{repositoryKey:repo,ruleKey:rule,name:Rule,severity:MAJOR,internalKey:rule,language:java,params:{param1:value1}}]," + + "activeRules:[{repositoryKey:repo,ruleKey:rule,templateRuleKey:templateRule,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,needBlame:true,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}," + "\"src/main/java/Foo2.java\":{hash:xyz,needBlame:false,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}," @@ -69,7 +69,7 @@ public class ProjectRepositoriesTest { ProjectRepositories ref = ProjectRepositories .fromJson("{timestamp:1," + "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"1984-03-14T00:00:00+0100\"}}," - + "activeRules:[{repositoryKey:repo,ruleKey:rule,name:Rule,severity:MAJOR,internalKey:rule1,language:java,params:{param1:value1}}]," + + "activeRules:[{repositoryKey:repo,ruleKey:rule,templateRuleKey:templateRule,name:Rule,severity:MAJOR,internalKey:rule1,language:java,params:{param1:value1}}]," + "settingsByModule:{foo:{prop:value}}," + "fileDataByModuleAndPath:{foo:{\"src/main/java/Foo.java\":{hash:xyz,needBlame:true,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}," + "lastAnalysisDate:\"2014-10-31T00:00:00+0100\"}"); @@ -79,6 +79,7 @@ public class ProjectRepositoriesTest { ActiveRule activeRule = ref.activeRules().iterator().next(); assertThat(activeRule.ruleKey()).isEqualTo("rule"); assertThat(activeRule.repositoryKey()).isEqualTo("repo"); + assertThat(activeRule.templateRuleKey()).isEqualTo("templateRule"); assertThat(activeRule.name()).isEqualTo("Rule"); assertThat(activeRule.severity()).isEqualTo("MAJOR"); assertThat(activeRule.internalKey()).isEqualTo("rule1"); |