From: Jean-Baptiste Lievremont Date: Fri, 10 Apr 2015 08:52:55 +0000 (+0200) Subject: SONAR-6294 Show active rule count even when it is 0 X-Git-Tag: 5.2-RC1~2320 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7445dff59d3dbfbb590823cd1140ede3d63fded1;p=sonarqube.git SONAR-6294 Show active rule count even when it is 0 --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileSearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileSearchAction.java index cbee96e3a49..ee9d94e83ac 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileSearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileSearchAction.java @@ -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 diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest.java index 6252a9d81e0..4d78c497a72 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest.java @@ -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 )); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest/search.json b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest/search.json index bc7499c23b2..1d49787a6c6 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest/search.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/ws/QProfileSearchActionTest/search.json @@ -25,7 +25,7 @@ "language": "xoo2", "languageName": "Xoo2", "isInherited": false, - "activeRuleCount": 22 + "activeRuleCount": 0 } ] } \ No newline at end of file