aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-20 21:46:50 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-20 21:46:50 +0000
commitea3eb66a50e49b349174b1c03e9567e79f8c6596 (patch)
tree2a3391e47d5b39140f23e6be60561cdd0d0c854b /tests
parentd3bac1b2a70bd187247e6c44ba35f09e1a5a44c6 (diff)
downloadsonarqube-ea3eb66a50e49b349174b1c03e9567e79f8c6596.tar.gz
sonarqube-ea3eb66a50e49b349174b1c03e9567e79f8c6596.zip
SONAR-833 time machine WS : improve SQL requests + better support of Q model characteristics
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/tests/src/test/java/org/sonar/tests/integration/ViolationsTimeMachineIT.java51
1 files changed, 26 insertions, 25 deletions
diff --git a/tests/integration/tests/src/test/java/org/sonar/tests/integration/ViolationsTimeMachineIT.java b/tests/integration/tests/src/test/java/org/sonar/tests/integration/ViolationsTimeMachineIT.java
index bc616289bf1..3d12a1612ca 100644
--- a/tests/integration/tests/src/test/java/org/sonar/tests/integration/ViolationsTimeMachineIT.java
+++ b/tests/integration/tests/src/test/java/org/sonar/tests/integration/ViolationsTimeMachineIT.java
@@ -6,12 +6,12 @@ import org.sonar.api.measures.CoreMetrics;
import org.sonar.wsclient.Sonar;
import org.sonar.wsclient.services.*;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
public class ViolationsTimeMachineIT {
@@ -33,24 +33,24 @@ public class ViolationsTimeMachineIT {
}
@Test
- public void timemachine() {
+ public void testHistoryOfViolations() {
TimeMachineQuery query = TimeMachineQuery.createForMetrics(PROJECT,
CoreMetrics.BLOCKER_VIOLATIONS_KEY,
CoreMetrics.CRITICAL_VIOLATIONS_KEY,
CoreMetrics.MAJOR_VIOLATIONS_KEY,
CoreMetrics.MINOR_VIOLATIONS_KEY,
CoreMetrics.INFO_VIOLATIONS_KEY);
- List<TimeMachineData> snapshots = sonar.findAll(query);
- assertThat(snapshots.size(), is(2));
+ TimeMachine timemachine = sonar.find(query);
+ assertThat(timemachine.getCells().length, is(2));
- TimeMachineData snapshot1 = snapshots.get(0);
- TimeMachineData snapshot2 = snapshots.get(1);
+ TimeMachineCell cell1 = timemachine.getCells()[0];
+ TimeMachineCell cell2 = timemachine.getCells()[1];
- assertThat(snapshot1.getDate().getMonth(), is(9));
- assertThat(snapshot1.getValues(), is(Arrays.asList("0.0", "0.0", "3.0", "4.0", "0.0")));
+ assertThat(cell1.getDate().getMonth(), is(9));
+ assertThat(cell1.getValues(), is(new Object[]{0.0, 0.0, 3.0, 4.0, 0.0}));
- assertThat(snapshot2.getDate().getMonth(), is(10));
- assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "5.0", "4.0", "0.0")));
+ assertThat(cell2.getDate().getMonth(), is(10));
+ assertThat(cell2.getValues(), is(new Object[]{0.0, 0.0, 5.0, 4.0, 0.0}));
}
@Test
@@ -72,34 +72,35 @@ public class ViolationsTimeMachineIT {
@Test
public void unknownMetrics() {
- List<TimeMachineData> snapshots = sonar.findAll(TimeMachineQuery.createForMetrics(PROJECT, "notfound"));
- assertThat(snapshots.size(), is(2));
- for (TimeMachineData data : snapshots) {
- assertThat(data.getValues().get(0), nullValue());
+ TimeMachine timemachine = sonar.find(TimeMachineQuery.createForMetrics(PROJECT, "notfound"));
+ assertThat(timemachine.getCells().length, is(2));
+ for (TimeMachineCell cell : timemachine.getCells()) {
+ assertThat(cell.getValues()[0], nullValue());
}
- snapshots = sonar.findAll(TimeMachineQuery.createForMetrics(PROJECT, CoreMetrics.LINES_KEY, "notfound"));
- assertThat(snapshots.size(), is(2));
- for (TimeMachineData data : snapshots) {
- assertThat(data.getValues().get(1), nullValue());
+ timemachine = sonar.find(TimeMachineQuery.createForMetrics(PROJECT, CoreMetrics.LINES_KEY, "notfound"));
+ assertThat(timemachine.getCells().length, is(2));
+ for (TimeMachineCell cell : timemachine.getCells()) {
+ assertThat(cell.getValues()[0], is(Double.class));
+ assertThat(cell.getValues()[1], nullValue());
}
- snapshots = sonar.findAll(TimeMachineQuery.createForMetrics(PROJECT));
- assertThat(snapshots.size(), is(0));
+ timemachine = sonar.find(TimeMachineQuery.createForMetrics(PROJECT));
+ assertThat(timemachine.getCells().length, is(0));
}
@Test
public void noDataForInterval() {
Date date = new Date();
- List<TimeMachineData> snapshots = sonar.findAll(TimeMachineQuery.createForMetrics(PROJECT, CoreMetrics.LINES_KEY)
+ TimeMachine timemachine = sonar.find(TimeMachineQuery.createForMetrics(PROJECT, CoreMetrics.LINES_KEY)
.setFrom(date)
.setTo(date));
- assertThat(snapshots.size(), is(0));
+ assertThat(timemachine.getCells().length, is(0));
}
@Test
public void unknownResource() {
- List<TimeMachineData> snapshots = sonar.findAll(TimeMachineQuery.createForMetrics("notfound:notfound", CoreMetrics.LINES_KEY));
- assertThat(snapshots.size(), is(0));
+ TimeMachine timemachine = sonar.find(TimeMachineQuery.createForMetrics("notfound:notfound", CoreMetrics.LINES_KEY));
+ assertNull(timemachine);
}
}