aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-07-23 15:25:28 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-07-23 16:59:58 +0200
commit81d3caaf7edc4a9ca7b9cf2ebb1ab68f99be96b8 (patch)
tree4e835706b7a2f4e00af869043f19b9b1fb9a354a /server/sonar-server
parent569ef40556dde0eb2a04c3fcdb12b79dd756d467 (diff)
downloadsonarqube-81d3caaf7edc4a9ca7b9cf2ebb1ab68f99be96b8.tar.gz
sonarqube-81d3caaf7edc4a9ca7b9cf2ebb1ab68f99be96b8.zip
Fix support of custom measure of metric of type LEVEL
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/CustomMeasuresCopyStepTest.java7
2 files changed, 10 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java
index 608bb3770b3..87c78862cb2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java
@@ -22,9 +22,9 @@ package org.sonar.server.computation.step;
import com.google.common.annotations.VisibleForTesting;
import java.util.List;
import org.apache.commons.lang.math.NumberUtils;
-import org.sonar.db.measure.custom.CustomMeasureDto;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
+import org.sonar.db.measure.custom.CustomMeasureDto;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DepthTraversalTypeAwareVisitor;
import org.sonar.server.computation.component.TreeRootHolder;
@@ -91,10 +91,11 @@ public class CustomMeasuresCopyStep implements ComputationStep {
return Measure.newMeasureBuilder().create(dto.getValue());
case BOOL:
return Measure.newMeasureBuilder().create(NumberUtils.compare(dto.getValue(), 1.0) == 0);
+ case LEVEL:
+ return Measure.newMeasureBuilder().create(Measure.Level.valueOf(dto.getTextValue()));
case STRING:
case DISTRIB:
case DATA:
- case LEVEL:
return Measure.newMeasureBuilder().create(dto.getTextValue());
default:
throw new IllegalArgumentException(String.format("Custom measures do not support the metric type [%s]", metric.getType()));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/CustomMeasuresCopyStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/CustomMeasuresCopyStepTest.java
index 9c406097f1f..9703827d4b7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/CustomMeasuresCopyStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/CustomMeasuresCopyStepTest.java
@@ -137,6 +137,13 @@ public class CustomMeasuresCopyStepTest {
}
@Test
+ public void test_LEVEL_value_type() throws Exception {
+ CustomMeasureDto dto = new CustomMeasureDto();
+ dto.setTextValue("OK");
+ assertThat(dtoToMeasure(dto, new MetricImpl(1, "m", "M", Metric.MetricType.LEVEL)).getLevelValue()).isEqualTo(Measure.Level.OK);
+ }
+
+ @Test
public void test_boolean_value_type() throws Exception {
MetricImpl booleanMetric = new MetricImpl(1, "m", "M", Metric.MetricType.BOOL);
CustomMeasureDto dto = new CustomMeasureDto();