]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6294 Show active rule count even when it is 0
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Fri, 10 Apr 2015 08:52:55 +0000 (10:52 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Fri, 10 Apr 2015 08:52:55 +0000 (10:52 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileSearchAction.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest/search.json

index cbee96e3a49fcd89dac80cba9655e45e12382324..ee9d94e83ac707426e453c70c918f0ff17c27ad0 100644 (file)
@@ -134,10 +134,11 @@ public class QProfileSearchAction implements BaseQProfileWsAction {
       }
 
       String key = profile.key();
+      Long activeRuleCount = activeRuleCountByKey.containsKey(key) ? activeRuleCountByKey.get(key) : 0L;
       json.beginObject()
         .prop(FIELD_KEY, nullUnlessNeeded(FIELD_KEY, key, fields))
         .prop(FIELD_NAME, nullUnlessNeeded(FIELD_NAME, profile.name(), fields))
-        .prop(FIELD_ACTIVE_RULE_COUNT, nullUnlessNeeded(FIELD_ACTIVE_RULE_COUNT, activeRuleCountByKey.get(key), fields));
+        .prop(FIELD_ACTIVE_RULE_COUNT, nullUnlessNeeded(FIELD_ACTIVE_RULE_COUNT, activeRuleCount, fields));
       writeLanguageFields(json, profile, fields);
       writeParentFields(json, profile, fields, profilesByKey);
       // Special case for booleans
index 6252a9d81e09f0c0ccc601ceb77a07745e641e9d..4d78c497a72a693e806478ed9256d2da1db75094 100644 (file)
@@ -86,7 +86,6 @@ public class QProfileSearchActionTest {
   public void search_nominal() throws Exception {
     when(profileLoader.countAllActiveRules()).thenReturn(ImmutableMap.of(
       "sonar-way-xoo1-12345", 11L,
-      "sonar-way-xoo2-23456", 22L,
       "my-sonar-way-xoo2-34567", 33L
       ));
 
index bc7499c23b25a31c66aee9efd52ab953e46437c6..1d49787a6c6842acd0055aedc95fe3e74ee78e20 100644 (file)
@@ -25,7 +25,7 @@
       "language": "xoo2",
       "languageName": "Xoo2",
       "isInherited": false,
-      "activeRuleCount": 22
+      "activeRuleCount": 0
     }
   ]
 }
\ No newline at end of file