From 90b80bd13929daf105060524bd5170b1b0d30e96 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 8 Nov 2016 14:16:59 +0100 Subject: [PATCH] Fix quality flaws --- .../test/java/org/sonar/db/metric/MetricDtoTest.java | 12 ++++++++++++ .../sonar/api/measures/CountDistributionBuilder.java | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sonar-db/src/test/java/org/sonar/db/metric/MetricDtoTest.java b/sonar-db/src/test/java/org/sonar/db/metric/MetricDtoTest.java index afd291e9ba6..f4cdcc235ec 100644 --- a/sonar-db/src/test/java/org/sonar/db/metric/MetricDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/metric/MetricDtoTest.java @@ -22,6 +22,9 @@ package org.sonar.db.metric; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.api.measures.Metric.ValueType.DATA; +import static org.sonar.api.measures.Metric.ValueType.INT; +import static org.sonar.api.measures.Metric.ValueType.STRING; public class MetricDtoTest { @@ -60,4 +63,13 @@ public class MetricDtoTest { assertThat(metricDto.isDeleteHistoricalData()).isTrue(); assertThat(metricDto.isEnabled()).isTrue(); } + + @Test + public void is_data_type() throws Exception { + assertThat(MetricTesting.newMetricDto().setValueType(INT.name()).isDataType()).isFalse(); + + assertThat(MetricTesting.newMetricDto().setValueType(DATA.name()).isDataType()).isTrue(); + assertThat(MetricTesting.newMetricDto().setValueType(STRING.name()).isDataType()).isTrue(); + assertThat(MetricTesting.newMetricDto().setValueType(STRING.name()).isDataType()).isTrue(); + } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CountDistributionBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CountDistributionBuilder.java index 5ab94f297e2..9ff08e55407 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CountDistributionBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CountDistributionBuilder.java @@ -22,6 +22,7 @@ package org.sonar.api.measures; import com.google.common.collect.Multiset; import com.google.common.collect.TreeMultiset; import java.util.Map; +import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.sonar.api.utils.KeyValueFormat; @@ -104,7 +105,7 @@ public class CountDistributionBuilder implements MeasureBuilder { * @param measure the measure to add to the current one * @return the current object */ - public CountDistributionBuilder add(Measure measure) { + public CountDistributionBuilder add(@Nullable Measure measure) { if (measure != null && measure.getData() != null) { Map map = KeyValueFormat.parse(measure.getData()); for (Map.Entry entry : map.entrySet()) { -- 2.39.5