diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-04-28 01:22:08 +0200 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-04-28 01:22:08 +0200 |
commit | bd604e40905e54bef42a206a8a638f03783aba3a (patch) | |
tree | a6adc8867f9473dfe09c7e719c0d0e6b81e9b99c /sonar-batch/src/test | |
parent | ffdc8908a25b4f5e071c1797d0bf7b40a9f9d8d5 (diff) | |
download | sonarqube-bd604e40905e54bef42a206a8a638f03783aba3a.tar.gz sonarqube-bd604e40905e54bef42a206a8a638f03783aba3a.zip |
SONAR-2202 Calculate variations on quality model measures
Diffstat (limited to 'sonar-batch/src/test')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java index 2b2137eb288..74e19b28ddf 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java @@ -32,6 +32,7 @@ import java.util.List; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.nullValue; import static org.junit.internal.matchers.IsCollectionContaining.hasItems; public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase { @@ -48,13 +49,18 @@ public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase { Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", PROJECT_SNAPSHOT_ID); PastMeasuresLoader loader = new PastMeasuresLoader(getSession(), metrics); - List<MeasureModel> measures = loader.getPastMeasures(FILE_ID, projectSnapshot); + List<Object[]> measures = loader.getPastMeasures(FILE_ID, projectSnapshot); assertThat(measures.size(), is(2)); - for (MeasureModel measure : measures) { - assertThat(measure.getId(), anyOf(is(5L), is(6L))); - assertThat(measure.getValue(), anyOf(is(5.0), is(60.0))); - } + Object[] pastMeasure = measures.get(0); + assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(1)); + assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue()); + assertThat(PastMeasuresLoader.getValue(pastMeasure), is(5.0)); + + pastMeasure = measures.get(1); + assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(2)); + assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue()); + assertThat(PastMeasuresLoader.getValue(pastMeasure), is(60.0)); } @Test @@ -65,13 +71,18 @@ public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase { Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", PROJECT_SNAPSHOT_ID); PastMeasuresLoader loader = new PastMeasuresLoader(getSession(), metrics); - List<MeasureModel> measures = loader.getPastMeasures(PROJECT_ID, projectSnapshot); + List<Object[]> measures = loader.getPastMeasures(PROJECT_ID, projectSnapshot); assertThat(measures.size(), is(2)); - for (MeasureModel measure : measures) { - assertThat(measure.getId(), anyOf(is(1L), is(2L))); - assertThat(measure.getValue(), anyOf(is(60.0), is(80.0))); - } + Object[] pastMeasure = measures.get(0); + assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(1)); + assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue()); + assertThat(PastMeasuresLoader.getValue(pastMeasure), is(60.0)); + + pastMeasure = measures.get(1); + assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(2)); + assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue()); + assertThat(PastMeasuresLoader.getValue(pastMeasure), is(80.0)); } @Test |