diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-30 15:58:16 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-30 15:58:16 +0200 |
commit | ca7396b9e6815c2e70d410f3b634fc10528a65ec (patch) | |
tree | a5f5f60bd5c4675d6d3ac2e07138a35f8cf5a8f8 /server/sonar-server | |
parent | cb839206f19fbf63ee60182d06b1eab0b45c3ce1 (diff) | |
download | sonarqube-ca7396b9e6815c2e70d410f3b634fc10528a65ec.tar.gz sonarqube-ca7396b9e6815c2e70d410f3b634fc10528a65ec.zip |
Add name to api/rules/list
Diffstat (limited to 'server/sonar-server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java | 4 | ||||
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java index 52be58caef3..8a4d5d0ce4c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java @@ -63,6 +63,10 @@ public class ListAction implements RulesWsAction { .clear() .setRepository(dto.getRepositoryKey()) .setKey(dto.getRuleKey()); + String name = dto.getName(); + if (!Strings.isNullOrEmpty(name)) { + ruleBuilder.setName(name); + } String internalKey = dto.getConfigKey(); if (!Strings.isNullOrEmpty(internalKey)) { ruleBuilder.setInternalKey(internalKey); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java index fd9aea6d1eb..21578d44051 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java @@ -50,8 +50,8 @@ public class ListActionTest { @Test public void return_rules_in_protobuf() throws Exception { - dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S001")).setConfigKey(null)); - dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S002")).setConfigKey("I002")); + dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S001")).setConfigKey(null).setName(null)); + dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S002")).setConfigKey("I002").setName("Rule Two")); dbTester.getSession().commit(); TestResponse response = tester.newRequest() @@ -64,7 +64,9 @@ public class ListActionTest { assertThat(listResponse.getRules(0).getKey()).isEqualTo("S001"); assertThat(listResponse.getRules(0).hasInternalKey()).isFalse(); + assertThat(listResponse.getRules(0).hasName()).isFalse(); assertThat(listResponse.getRules(1).getKey()).isEqualTo("S002"); assertThat(listResponse.getRules(1).getInternalKey()).isEqualTo("I002"); + assertThat(listResponse.getRules(1).getName()).isEqualTo("Rule Two"); } } |