aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-20 13:00:40 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-21 17:31:54 +0200
commitd9ac0b473f325cc94db3a800a1dcbe9c681def7d (patch)
tree4d32d826eebca427b02635e8f51b0fe16300783b /server
parent13a93c6473782384b468c98c8bfebfe51d75a655 (diff)
downloadsonarqube-d9ac0b473f325cc94db3a800a1dcbe9c681def7d.tar.gz
sonarqube-d9ac0b473f325cc94db3a800a1dcbe9c681def7d.zip
Remove variation usage from BatchMeasureToMeasure
The batch do not send anymore variationd data as there are now computed in CE
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java39
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java33
2 files changed, 7 insertions, 65 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java
index 41a4e49cb77..a7931c61116 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java
@@ -61,35 +61,35 @@ public class BatchMeasureToMeasure {
if (!batchMeasure.hasIntValue()) {
return toNoValueMeasure(builder, batchMeasure);
}
- return of(setCommonProperties(builder, batchMeasure).create(batchMeasure.getIntValue(), data));
+ return of(builder.create(batchMeasure.getIntValue(), data));
}
private static Optional<Measure> toLongMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure, @Nullable String data) {
if (!batchMeasure.hasLongValue()) {
return toNoValueMeasure(builder, batchMeasure);
}
- return of(setCommonProperties(builder, batchMeasure).create(batchMeasure.getLongValue(), data));
+ return of(builder.create(batchMeasure.getLongValue(), data));
}
private static Optional<Measure> toDoubleMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure, @Nullable String data) {
if (!batchMeasure.hasDoubleValue()) {
return toNoValueMeasure(builder, batchMeasure);
}
- return of(setCommonProperties(builder, batchMeasure).create(batchMeasure.getDoubleValue(), data));
+ return of(builder.create(batchMeasure.getDoubleValue(), data));
}
private static Optional<Measure> toBooleanMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure, @Nullable String data) {
if (!batchMeasure.hasBooleanValue()) {
return toNoValueMeasure(builder, batchMeasure);
}
- return of(setCommonProperties(builder, batchMeasure).create(batchMeasure.getBooleanValue(), data));
+ return of(builder.create(batchMeasure.getBooleanValue(), data));
}
private static Optional<Measure> toStringMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) {
if (!batchMeasure.hasStringValue()) {
return toNoValueMeasure(builder, batchMeasure);
}
- return of(setCommonProperties(builder, batchMeasure).create(batchMeasure.getStringValue()));
+ return of(builder.create(batchMeasure.getStringValue()));
}
private static Optional<Measure> toLevelMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) {
@@ -100,35 +100,10 @@ public class BatchMeasureToMeasure {
if (!level.isPresent()) {
return toNoValueMeasure(builder, batchMeasure);
}
- return of(setCommonProperties(builder, batchMeasure).create(level.get()));
+ return of(builder.create(level.get()));
}
private static Optional<Measure> toNoValueMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) {
- return of(setCommonProperties(builder, batchMeasure).createNoValue());
+ return of(builder.createNoValue());
}
-
- private static Measure.NewMeasureBuilder setCommonProperties(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) {
- if (hasAnyVariation(batchMeasure)) {
- builder.setVariations(createVariations(batchMeasure));
- }
- return builder;
- }
-
- private static boolean hasAnyVariation(BatchReport.Measure batchMeasure) {
- return batchMeasure.hasVariationValue1()
- || batchMeasure.hasVariationValue2()
- || batchMeasure.hasVariationValue3()
- || batchMeasure.hasVariationValue4()
- || batchMeasure.hasVariationValue5();
- }
-
- private static MeasureVariations createVariations(BatchReport.Measure batchMeasure) {
- return new MeasureVariations(
- batchMeasure.hasVariationValue1() ? batchMeasure.getVariationValue1() : null,
- batchMeasure.hasVariationValue2() ? batchMeasure.getVariationValue2() : null,
- batchMeasure.hasVariationValue3() ? batchMeasure.getVariationValue3() : null,
- batchMeasure.hasVariationValue4() ? batchMeasure.getVariationValue4() : null,
- batchMeasure.hasVariationValue5() ? batchMeasure.getVariationValue5() : null);
- }
-
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java
index c00155eb02f..bfde58d2296 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java
@@ -22,7 +22,6 @@ package org.sonar.server.computation.measure;
import com.google.common.base.Optional;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
-import com.tngtech.java.junit.dataprovider.UseDataProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.sonar.batch.protocol.output.BatchReport;
@@ -276,36 +275,4 @@ public class BatchMeasureToMeasureTest {
{BatchReport.Measure.newBuilder().setStringValue(Measure.Level.OK.name()), SOME_LEVEL_METRIC}
};
}
-
- @Test
- @UseDataProvider("all_types_batch_measure_builders")
- public void toMeasure_creates_no_MeasureVariation_if_dto_has_none_whichever_the_ValueType(BatchReport.Measure.Builder builder, Metric metric) {
- assertThat(underTest.toMeasure(builder.build(), metric).get().hasVariations()).isFalse();
- }
-
- @Test
- @UseDataProvider("all_types_batch_measure_builders")
- public void toMeasure_creates_MeasureVariation_and_maps_the_right_one(BatchReport.Measure.Builder builder, Metric metric) {
- assertThat(underTest.toMeasure(builder.setVariationValue1(1).build(), metric).get().getVariations().getVariation1()).isEqualTo(1);
- assertThat(underTest.toMeasure(builder.setVariationValue2(2).build(), metric).get().getVariations().getVariation2()).isEqualTo(2);
- assertThat(underTest.toMeasure(builder.setVariationValue3(3).build(), metric).get().getVariations().getVariation3()).isEqualTo(3);
- assertThat(underTest.toMeasure(builder.setVariationValue4(4).build(), metric).get().getVariations().getVariation4()).isEqualTo(4);
- assertThat(underTest.toMeasure(builder.setVariationValue5(5).build(), metric).get().getVariations().getVariation5()).isEqualTo(5);
- }
-
- @Test
- public void toMeasure_creates_MeasureVariation_and_maps_the_right_one() {
- BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder()
- .setStringValue("1").setVariationValue2(2).setVariationValue3(3).setVariationValue5(5)
- .build();
-
- Optional<Measure> measure = underTest.toMeasure(batchMeasure, SOME_STRING_METRIC);
-
- assertThat(measure.get().getVariations().hasVariation1()).isFalse();
- assertThat(measure.get().getVariations().getVariation2()).isEqualTo(2);
- assertThat(measure.get().getVariations().getVariation3()).isEqualTo(3);
- assertThat(measure.get().getVariations().hasVariation4()).isFalse();
- assertThat(measure.get().getVariations().getVariation5()).isEqualTo(5);
- }
-
}