diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-15 14:35:33 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-15 14:35:33 +0000 |
commit | 9e75d602fcaf9975d945224ec1548a143c77c5b3 (patch) | |
tree | c105fa4d23614bfdfd7ec9594ea88d8764b212e2 /tests | |
parent | dfbfcb1f08d1c8ab26e786f508f98958f178aee3 (diff) | |
download | sonarqube-9e75d602fcaf9975d945224ec1548a143c77c5b3.tar.gz sonarqube-9e75d602fcaf9975d945224ec1548a143c77c5b3.zip |
SONAR-249 rename FILTERS.VARIATION_INDEX to FILTERS.PERIOD_INDEX + support variations in the resources web service + add IT
Diffstat (limited to 'tests')
3 files changed, 51 insertions, 1 deletions
diff --git a/tests/integration/tests/custom-projects/violations-timemachine/v2/src/main/java/org/sonar/tests/violationstimemachine/SecondFileAddedInV2.java b/tests/integration/tests/custom-projects/violations-timemachine/v2/src/main/java/org/sonar/tests/violationstimemachine/SecondFileAddedInV2.java new file mode 100644 index 00000000000..bddd7f0c346 --- /dev/null +++ b/tests/integration/tests/custom-projects/violations-timemachine/v2/src/main/java/org/sonar/tests/violationstimemachine/SecondFileAddedInV2.java @@ -0,0 +1,10 @@ +package org.sonar.tests.violationstimemachine; + +public class SecondFileAddedInV2 { + + public void hasOneViolation() { + int i = 0; // unused local variable + i++; + } + +} diff --git a/tests/integration/tests/src/test/java/org/sonar/tests/integration/VariationsIT.java b/tests/integration/tests/src/test/java/org/sonar/tests/integration/VariationsIT.java index 20307d6367a..e794306ddad 100644 --- a/tests/integration/tests/src/test/java/org/sonar/tests/integration/VariationsIT.java +++ b/tests/integration/tests/src/test/java/org/sonar/tests/integration/VariationsIT.java @@ -19,5 +19,45 @@ */ package org.sonar.tests.integration; +import org.junit.BeforeClass; +import org.junit.Test; +import org.sonar.wsclient.Sonar; +import org.sonar.wsclient.services.Resource; +import org.sonar.wsclient.services.ResourceQuery; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.junit.Assert.assertThat; + public class VariationsIT { + + private static final String TIMEMACHINE_PROJECT = "org.sonar.tests:violations-timemachine"; + + private static Sonar sonar; + + @BeforeClass + public static void buildServer() { + sonar = ITUtils.createSonarWsClient(); + } + + @Test + public void checkBaseVariations() { + + Resource project = getProject("files", "ncloc", "violations"); + + // period 1 : previous analysis + assertThat(project.getPeriod1Mode(), is("previous_analysis")); + assertThat(project.getPeriod1Date(), notNullValue()); + + // variations from previous analysis + assertThat(project.getMeasure("files").getVariation1(), is(1.0)); + assertThat(project.getMeasure("ncloc").getVariation1(), is(8.0)); + assertThat(project.getMeasure("violations").getVariation1(), greaterThan(0.0)); + } + + private Resource getProject(String... metricKeys) { + return sonar.find(ResourceQuery.createForMetrics(TIMEMACHINE_PROJECT, metricKeys).setIncludeTrends(true)); + } + } 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 14d2774abf7..f3b07ef6d6c 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 @@ -48,7 +48,7 @@ public class ViolationsTimeMachineIT { assertThat(snapshot1.getValues(), is(Arrays.asList("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", "4.0", "3.0", "0.0"))); + assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "5.0", "4.0", "0.0"))); } @Test |