summaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-06-21 15:12:11 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-06-21 15:13:48 +0200
commit02fdeba8d5cea42b17f0e24bc1d0bdebd9c0d29b (patch)
tree56b6d7bb26a1b842577c75968269ad3ae9e976ef /sonar-batch/src/test
parent09b9a9586fe2a3a82d79ea2e7c5f1cbe742c8ac5 (diff)
downloadsonarqube-02fdeba8d5cea42b17f0e24bc1d0bdebd9c0d29b.tar.gz
sonarqube-02fdeba8d5cea42b17f0e24bc1d0bdebd9c0d29b.zip
SONAR-2505 support measure variations
Diffstat (limited to 'sonar-batch/src/test')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java10
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java12
2 files changed, 10 insertions, 12 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 74e19b28ddf..40c253e78b3 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
@@ -20,10 +20,8 @@
package org.sonar.batch.components;
import org.junit.Test;
-import org.sonar.api.database.model.MeasureModel;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.measures.Metric;
-import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.util.Arrays;
@@ -38,8 +36,8 @@ import static org.junit.internal.matchers.IsCollectionContaining.hasItems;
public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase {
private static final int PROJECT_SNAPSHOT_ID = 1000;
- private static final int PROJECT_ID = 1;
- private static final int FILE_ID = 3;
+ private static final String PROJECT_KEY = "project";
+ private static final String FILE_KEY = "project:org.foo.Bar";
@Test
public void shouldGetPastResourceMeasures() {
@@ -49,7 +47,7 @@ public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase {
Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", PROJECT_SNAPSHOT_ID);
PastMeasuresLoader loader = new PastMeasuresLoader(getSession(), metrics);
- List<Object[]> measures = loader.getPastMeasures(FILE_ID, projectSnapshot);
+ List<Object[]> measures = loader.getPastMeasures(FILE_KEY, projectSnapshot);
assertThat(measures.size(), is(2));
Object[] pastMeasure = measures.get(0);
@@ -71,7 +69,7 @@ public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase {
Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", PROJECT_SNAPSHOT_ID);
PastMeasuresLoader loader = new PastMeasuresLoader(getSession(), metrics);
- List<Object[]> measures = loader.getPastMeasures(PROJECT_ID, projectSnapshot);
+ List<Object[]> measures = loader.getPastMeasures(PROJECT_KEY, projectSnapshot);
assertThat(measures.size(), is(2));
Object[] pastMeasure = measures.get(0);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java
index 8bd305e85e2..d403bd0b7a0 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java
@@ -33,37 +33,37 @@ public class PastSnapshotTest {
@Test
public void testToStringForVersion() {
- PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByVersion.MODE, new Date()).setModeParameter("2.3");
+ PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_VERSION, new Date()).setModeParameter("2.3");
assertThat(pastSnapshot.toString(), startsWith("Compare to version 2.3"));
}
@Test
public void testToStringForVersionWithoutDate() {
- PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByVersion.MODE).setModeParameter("2.3");
+ PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_VERSION).setModeParameter("2.3");
assertThat(pastSnapshot.toString(), equalTo("Compare to version 2.3"));
}
@Test
public void testToStringForNumberOfDays() {
- PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByDays.MODE, new Date()).setModeParameter("30");
+ PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_DAYS, new Date()).setModeParameter("30");
assertThat(pastSnapshot.toString(), startsWith("Compare over 30 days ("));
}
@Test
public void testToStringForNumberOfDaysWithSnapshot() {
- PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByDays.MODE, new Date(), new Snapshot().setCreatedAt(new Date())).setModeParameter("30");
+ PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_DAYS, new Date(), new Snapshot().setCreatedAt(new Date())).setModeParameter("30");
assertThat(pastSnapshot.toString(), startsWith("Compare over 30 days ("));
}
@Test
public void testToStringForDate() {
- PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByDate.MODE, new Date());
+ PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_DATE, new Date());
assertThat(pastSnapshot.toString(), startsWith("Compare to date "));
}
@Test
public void testToStringForDateWithSnapshot() {
- PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByDate.MODE, new Date(), new Snapshot().setCreatedAt(new Date()));
+ PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_DATE, new Date(), new Snapshot().setCreatedAt(new Date()));
assertThat(pastSnapshot.toString(), startsWith("Compare to date "));
}