aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-06-01 11:22:34 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-06-01 11:22:34 +0200
commit481216a731cb25a7d1619c30dd173f12e1625e28 (patch)
treee5e1c541d237c45fa31f84ae19e67dc50355af6d /server
parentdf0e388a524ebf11978e9961e9b6f25a184d9dba (diff)
downloadsonarqube-481216a731cb25a7d1619c30dd173f12e1625e28.tar.gz
sonarqube-481216a731cb25a7d1619c30dd173f12e1625e28.zip
Fix a test isolation and replace field MeasureDto.projectId by componentId
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java45
1 files changed, 28 insertions, 17 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java
index cc0acaff668..bd845ac6ffd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java
@@ -20,6 +20,11 @@
package org.sonar.server.computation.step;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
@@ -59,12 +64,6 @@ import org.sonar.server.rule.RuleTesting;
import org.sonar.server.rule.db.RuleDao;
import org.sonar.test.DbTests;
-import java.io.File;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -211,7 +210,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
@Test
public void map_full_batch_measure() {
BatchReport.Component component = defaultComponent().build();
- addComponent(component.getRef(), "component-key");
+ ComponentDto componentDto = addComponent(component.getRef(), "component-key");
BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder()
.setValueType(MeasureValueType.DOUBLE)
@@ -233,13 +232,29 @@ public class PersistMeasuresStepTest extends BaseStepTest {
MeasureDto measure = sut.toMeasureDto(batchMeasure, component);
- assertThat(measure).isEqualToComparingFieldByField(expectedFullMeasure());
+ assertThat(measure).isEqualToComparingFieldByField(new MeasureDto()
+ .setComponentId(componentDto.getId())
+ .setSnapshotId(3L)
+ .setCharacteristicId(123456)
+ .setPersonId(5432)
+ .setValue(123.123d)
+ .setVariation(1, 1.1d)
+ .setVariation(2, 2.2d)
+ .setVariation(3, 3.3d)
+ .setVariation(4, 4.4d)
+ .setVariation(5, 5.5d)
+ .setAlertStatus("WARN")
+ .setAlertText("Open issues > 0")
+ .setDescription("measure-description")
+ .setSeverity(Severity.CRITICAL)
+ .setMetricId(metric.getId())
+ .setRuleId(rule.getId()));
}
@Test
public void map_minimal_batch_measure() {
BatchReport.Component component = defaultComponent().build();
- addComponent(component.getRef(), "component-key");
+ ComponentDto componentDto = addComponent(component.getRef(), "component-key");
BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder()
.setValueType(MeasureValueType.INT)
@@ -248,7 +263,10 @@ public class PersistMeasuresStepTest extends BaseStepTest {
MeasureDto measure = sut.toMeasureDto(batchMeasure, component);
- assertThat(measure).isEqualToComparingFieldByField(expectedMinimalistMeasure());
+ assertThat(measure).isEqualToComparingFieldByField(new MeasureDto()
+ .setComponentId(componentDto.getId())
+ .setSnapshotId(3L)
+ .setMetricId(metric.getId()));
}
@Test
@@ -415,13 +433,6 @@ public class PersistMeasuresStepTest extends BaseStepTest {
.setRuleId(rule.getId());
}
- private MeasureDto expectedMinimalistMeasure() {
- return new MeasureDto()
- .setComponentId(2L)
- .setSnapshotId(3L)
- .setMetricId(metric.getId());
- }
-
private BatchReport.Component.Builder defaultComponent() {
return BatchReport.Component.newBuilder()
.setRef(1)