From e6203dbc6e7e1d8516dc8243afdaf3a7c41270a6 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Wed, 6 Jul 2016 14:52:23 +0200 Subject: [PATCH] SONAR-7869 api/measures/* formats correctly big MILLISEC metrics --- .../org/sonar/server/measure/ws/MeasureValueFormatter.java | 4 ++-- .../sonar/server/measure/ws/MeasureValueFormatterTest.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java index fcf5e28bd22..84dfacc77a2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java @@ -39,8 +39,8 @@ class MeasureValueFormatter { case BOOL: return formatBoolean(doubleValue); case INT: - case MILLISEC: return formatInteger(doubleValue); + case MILLISEC: case WORK_DUR: return formatLong(doubleValue); case FLOAT: @@ -64,8 +64,8 @@ class MeasureValueFormatter { case BOOL: return formatBoolean(value); case INT: - case MILLISEC: return formatInteger(value); + case MILLISEC: case WORK_DUR: return formatLong(value); case FLOAT: diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureValueFormatterTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureValueFormatterTest.java index 9ad6ea678e5..e2c7d8f3669 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureValueFormatterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/MeasureValueFormatterTest.java @@ -50,6 +50,7 @@ public class MeasureValueFormatterTest { assertThat(formatNumericalValue(1_000.123d, newMetric(FLOAT))).isEqualTo("1000.123"); assertThat(formatNumericalValue(1_000.0d, newMetric(INT))).isEqualTo("1000"); assertThat(formatNumericalValue(1_000.0d, newMetric(WORK_DUR))).isEqualTo("1000"); + assertThat(formatNumericalValue(6_000_000_000_000.0d, newMetric(MILLISEC))).isEqualTo("6000000000000"); } @Test @@ -57,8 +58,8 @@ public class MeasureValueFormatterTest { assertThat(formatMeasureValue(newNumericMeasure(-1.0d), newMetric(BOOL))).isEqualTo("false"); assertThat(formatMeasureValue(newNumericMeasure(1.0d), newMetric(BOOL))).isEqualTo("true"); assertThat(formatMeasureValue(newNumericMeasure(1000.123d), newMetric(PERCENT))).isEqualTo("1000.123"); - assertThat(formatMeasureValue(newNumericMeasure(1000d), newMetric(MILLISEC))).isEqualTo("1000"); assertThat(formatMeasureValue(newNumericMeasure(1000.0d), newMetric(WORK_DUR))).isEqualTo("1000"); + assertThat(formatMeasureValue(newNumericMeasure(6_000_000_000_000.0d), newMetric(MILLISEC))).isEqualTo("6000000000000"); assertThat(formatMeasureValue(newTextMeasure("text-value"), newMetric(DATA))).isEqualTo("text-value"); } -- 2.39.5