diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-02-09 12:06:35 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-02-09 12:33:49 +0100 |
commit | b49f4a0e2dc098099f2172e24a48768a983f96f5 (patch) | |
tree | 1691ee77bfb8cc247e940c57351cddb45a46442f /sonar-batch-protocol/src | |
parent | 1a967d04eae33998087b7ee09068c9fb05a8696a (diff) | |
download | sonarqube-b49f4a0e2dc098099f2172e24a48768a983f96f5.tar.gz sonarqube-b49f4a0e2dc098099f2172e24a48768a983f96f5.zip |
SONAR-6162 Return template rule key in /batch/projects WS
Diffstat (limited to 'sonar-batch-protocol/src')
-rw-r--r-- | sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java | 10 | ||||
-rw-r--r-- | sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java | 7 |
2 files changed, 12 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 4fda09f8910..157253fa056 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,14 @@ 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, String severity, @Nullable String internalKey, String language) { + public ActiveRule(String repositoryKey, String ruleKey, @Nullable String templateRuleKey, String name, String severity, @Nullable String internalKey, String language) { this.repositoryKey = repositoryKey; this.ruleKey = ruleKey; + this.templateRuleKey = templateRuleKey; this.name = name; this.severity = severity; this.internalKey = internalKey; @@ -47,6 +48,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/ProjectReferentialsTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java index 8d55f4054dc..c446e11aa9e 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 @@ -45,7 +45,7 @@ public class ProjectReferentialsTest { 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")); @@ -57,7 +57,7 @@ public class ProjectReferentialsTest { .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,scmLastCommitDatetimesByLine:\"1\u003d12345,2\u003d3456\",scmRevisionsByLine:\"1\u003d345,2\u003d345\",scmAuthorsByLine:\"1\u003dhenryju,2\u003dgaudin\"}}}," + "lastAnalysisDate:\"2014-10-31T00:00:00+0100\"}", @@ -69,7 +69,7 @@ public class ProjectReferentialsTest { ProjectReferentials ref = ProjectReferentials .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,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 ProjectReferentialsTest { 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"); |