import java.util.List;
public class UserManagedMetrics implements Metrics {
+ private static final String DOMAIN = "Management";
+
public List<Metric> 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));
}
}
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<Metric> metrics = userManagedMetrics.getMetrics();
+ assertThat(metrics.size(), greaterThan(2));
+ for (Metric metric : metrics) {
+ assertThat(metric.getUserManaged(), is(true));
+ assertThat(metric.getDomain(), is("Management"));
+ }
}
}