From fcd0d57b85fcc029d8fa2e05d6e03fd9225c8134 Mon Sep 17 00:00:00 2001 From: Godin Date: Thu, 2 Dec 2010 23:56:05 +0000 Subject: [PATCH] Fix violations reported on Nemo. --- .../plugins/core/metrics/UserManagedMetrics.java | 14 ++++++++++---- .../core/metrics/UserManagedMetricsTest.java | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java index d6a2bfbbe3f..1f8d5a79a9e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/metrics/UserManagedMetrics.java @@ -26,11 +26,17 @@ import java.util.Arrays; import java.util.List; public class UserManagedMetrics implements Metrics { + private static final String DOMAIN = "Management"; + public List getMetrics() { return Arrays.asList( - new Metric("burned_budget", "Burned budget", "The budget already used in the project", Metric.ValueType.FLOAT, 0, false, "Management", true), - new Metric("team_size", "Team size", "Size of the project team", Metric.ValueType.INT, 0, false, "Management", true), - new Metric("business_value", "Business value", "An indication on the value of the project for the business", Metric.ValueType.FLOAT, 1, true, "Management", true) - ); + new Metric("burned_budget", "Burned budget", "The budget already used in the project", Metric.ValueType.FLOAT, + Metric.DIRECTION_NONE, false, DOMAIN) + .setUserManaged(true), + new Metric("team_size", "Team size", "Size of the project team", Metric.ValueType.INT, Metric.DIRECTION_NONE, false, DOMAIN) + .setUserManaged(true), + new Metric("business_value", "Business value", "An indication on the value of the project for the business", + Metric.ValueType.FLOAT, Metric.DIRECTION_BETTER, true, DOMAIN) + .setUserManaged(true)); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/metrics/UserManagedMetricsTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/metrics/UserManagedMetricsTest.java index 72158fdbe88..7ce01bb0ae1 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/metrics/UserManagedMetricsTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/metrics/UserManagedMetricsTest.java @@ -20,14 +20,24 @@ package org.sonar.plugins.core.metrics; import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; + import org.junit.Test; +import org.sonar.api.measures.Metric; + +import java.util.List; public class UserManagedMetricsTest { @Test public void checkDefinitions() { - UserManagedMetrics metrics = new UserManagedMetrics(); - assertThat(metrics.getMetrics().size(), greaterThan(2)); + UserManagedMetrics userManagedMetrics = new UserManagedMetrics(); + List metrics = userManagedMetrics.getMetrics(); + assertThat(metrics.size(), greaterThan(2)); + for (Metric metric : metrics) { + assertThat(metric.getUserManaged(), is(true)); + assertThat(metric.getDomain(), is("Management")); + } } } -- 2.39.5