diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-05-29 15:01:40 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-05-29 16:01:15 +0200 |
commit | ff83bd8afede243c807dbf025bb9839bcbc2f88e (patch) | |
tree | 0269172e15fe861b8015ed31031c54873d4142e7 | |
parent | 2df15e648ef11b6e3ec40dae2a93ad250cb62170 (diff) | |
download | sonarqube-ff83bd8afede243c807dbf025bb9839bcbc2f88e.tar.gz sonarqube-ff83bd8afede243c807dbf025bb9839bcbc2f88e.zip |
SONAR-6576 WS api/metrics/domains returns domains of enabled metrics only
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java | 19 | ||||
-rw-r--r-- | sonar-core/src/main/resources/org/sonar/core/metric/db/MetricMapper.xml | 2 |
2 files changed, 13 insertions, 8 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java index b68d4bd0db6..2a83576fecd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DomainsActionTest.java @@ -57,13 +57,14 @@ public class DomainsActionTest { @Test public void json_example_validated() throws Exception { - insertNewMetricDto(MetricTesting.newDto().setDomain("API Compatibility")); - insertNewMetricDto(MetricTesting.newDto().setDomain("Issues")); - insertNewMetricDto(MetricTesting.newDto().setDomain("Rules")); - insertNewMetricDto(MetricTesting.newDto().setDomain("Tests")); - insertNewMetricDto(MetricTesting.newDto().setDomain("Documentation")); - insertNewMetricDto(MetricTesting.newDto().setDomain(null)); - insertNewMetricDto(MetricTesting.newDto().setDomain("")); + insertNewMetricDto(newEnabledMetric("API Compatibility")); + insertNewMetricDto(newEnabledMetric("Issues")); + insertNewMetricDto(newEnabledMetric("Rules")); + insertNewMetricDto(newEnabledMetric("Tests")); + insertNewMetricDto(newEnabledMetric("Documentation")); + insertNewMetricDto(newEnabledMetric(null)); + insertNewMetricDto(newEnabledMetric("")); + insertNewMetricDto(MetricTesting.newDto().setDomain("Domain of Deactivated Metric").setEnabled(false)); WsTester.Result result = ws.newGetRequest(MetricsWs.ENDPOINT, "domains").execute(); @@ -74,4 +75,8 @@ public class DomainsActionTest { dbClient.metricDao().insert(dbSession, metric); dbSession.commit(); } + + private MetricDto newEnabledMetric(String domain) { + return MetricTesting.newDto().setDomain(domain).setEnabled(true); + } } diff --git a/sonar-core/src/main/resources/org/sonar/core/metric/db/MetricMapper.xml b/sonar-core/src/main/resources/org/sonar/core/metric/db/MetricMapper.xml index 4c38d99c12a..2e638309850 100644 --- a/sonar-core/src/main/resources/org/sonar/core/metric/db/MetricMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/metric/db/MetricMapper.xml @@ -66,7 +66,7 @@ <select id="selectDomains" resultType="String"> select distinct domain from metrics m - where m.domain is not null + where m.domain is not null and m.enabled=${_true} </select> <update id="disable"> |