From ff83bd8afede243c807dbf025bb9839bcbc2f88e Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Fri, 29 May 2015 15:01:40 +0200 Subject: SONAR-6576 WS api/metrics/domains returns domains of enabled metrics only --- .../org/sonar/server/metric/ws/DomainsActionTest.java | 19 ++++++++++++------- .../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 @@ -- cgit v1.2.3