diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-06-17 14:55:40 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-06-17 17:18:45 +0400 |
commit | c973498cfec4ff8e59ac33e9c9fb150a71ef828a (patch) | |
tree | 276e8ac2d6ba96b6edeb4622c6702ae19f988251 /sonar-batch/src/test | |
parent | 58c0a485ceade20933b5bc52b914ef2b34cadbd5 (diff) | |
download | sonarqube-c973498cfec4ff8e59ac33e9c9fb150a71ef828a.tar.gz sonarqube-c973498cfec4ff8e59ac33e9c9fb150a71ef828a.zip |
SONAR-2428 Detection new violations, when new module added to project
Diffstat (limited to 'sonar-batch/src/test')
3 files changed, 32 insertions, 7 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java index 9e6cb1b98b7..f36e6fea13d 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java @@ -52,6 +52,6 @@ public class PastSnapshotFinderByPreviousAnalysisTest extends AbstractDbUnitTest PastSnapshot pastSnapshot = finder.findByPreviousAnalysis(projectSnapshot); assertThat(pastSnapshot.isRelatedToSnapshot(), is(false)); assertThat(pastSnapshot.getProjectSnapshot(), nullValue()); - assertThat(projectSnapshot.getCreatedAt().getTime() - pastSnapshot.getTargetDate().getTime(), is(1000L * 60)); + assertThat(pastSnapshot.getTargetDate(), nullValue()); } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByVersionTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByVersionTest.java index 046610f5e0b..5ad41e4c808 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByVersionTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByVersionTest.java @@ -49,6 +49,6 @@ public class PastSnapshotFinderByVersionTest extends AbstractDbUnitTestCase { PastSnapshot pastSnapshot = finder.findByVersion(currentProjectSnapshot, "1.0"); assertThat(pastSnapshot.isRelatedToSnapshot(), is(false)); assertThat(pastSnapshot.getProjectSnapshot(), nullValue()); - assertThat(currentProjectSnapshot.getCreatedAt().getTime() - pastSnapshot.getTargetDate().getTime(), is(1000L * 60)); + assertThat(pastSnapshot.getTargetDate(), nullValue()); } } 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 48fd131f125..8bd305e85e2 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 @@ -19,15 +19,16 @@ */ package org.sonar.batch.components; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.startsWith; +import static org.junit.Assert.assertThat; + import org.junit.Test; import org.sonar.api.CoreProperties; import org.sonar.api.database.model.Snapshot; import java.util.Date; -import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; - public class PastSnapshotTest { @Test @@ -37,9 +38,21 @@ public class PastSnapshotTest { } @Test + public void testToStringForVersionWithoutDate() { + PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByVersion.MODE).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"); - assertThat(pastSnapshot.toString(), startsWith("Compare over 30 days")); + 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"); + assertThat(pastSnapshot.toString(), startsWith("Compare over 30 days (")); } @Test @@ -49,8 +62,20 @@ public class PastSnapshotTest { } @Test + public void testToStringForDateWithSnapshot() { + PastSnapshot pastSnapshot = new PastSnapshot(PastSnapshotFinderByDate.MODE, new Date(), new Snapshot().setCreatedAt(new Date())); + assertThat(pastSnapshot.toString(), startsWith("Compare to date ")); + } + + @Test public void testToStringForPreviousAnalysis() { PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, new Date(), new Snapshot().setCreatedAt(new Date())); - assertThat(pastSnapshot.toString(), startsWith("Compare to previous analysis")); + assertThat(pastSnapshot.toString(), startsWith("Compare to previous analysis ")); + } + + @Test + public void testToStringForPreviousAnalysisWithoutDate() { + PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS); + assertThat(pastSnapshot.toString(), equalTo("Compare to previous analysis")); } } |