diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-08 18:15:49 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-08 18:15:49 +0100 |
commit | 4be8b53738bd6dd2a02c0bb9f1952d3cf6d9a361 (patch) | |
tree | 49043b6f26f9fb01eef6dee28cdff5ece5390191 /plugins/sonar-core-plugin/src | |
parent | 06770b3ba35667e66028fd969e356bbdae44d55d (diff) | |
download | sonarqube-4be8b53738bd6dd2a02c0bb9f1952d3cf6d9a361.tar.gz sonarqube-4be8b53738bd6dd2a02c0bb9f1952d3cf6d9a361.zip |
SONAR-2218 coverage of new code must be computed even if there are no previous analysis
Diffstat (limited to 'plugins/sonar-core-plugin/src')
3 files changed, 12 insertions, 15 deletions
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java index 90481c78e65..afc51cf8969 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java @@ -21,12 +21,12 @@ package org.sonar.plugins.core.timemachine; import org.junit.Test; import org.sonar.api.database.model.Snapshot; +import org.sonar.api.utils.DateUtils; import org.sonar.batch.components.PastSnapshot; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.Arrays; import static org.mockito.Mockito.mock; @@ -37,13 +37,12 @@ public class TimeMachineConfigurationPersisterTest extends AbstractDbUnitTestCas @Test public void shouldSaveConfigurationInSnapshotsTable() throws ParseException { setupData("shared"); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); TimeMachineConfiguration conf = mock(TimeMachineConfiguration.class); - PastSnapshot vs1 = new PastSnapshot("days", getSession().getSingleResult(Snapshot.class, "id", 100)) - .setModeParameter("30").setIndex(1).setTargetDate(format.parse("2009-01-25")); - PastSnapshot vs3 = new PastSnapshot("version", getSession().getSingleResult(Snapshot.class, "id", 300)) - .setModeParameter("1.2.3").setIndex(3).setTargetDate(format.parse("2008-12-13")); + PastSnapshot vs1 = new PastSnapshot("days", DateUtils.parseDate("2009-01-25"), getSession().getSingleResult(Snapshot.class, "id", 100)) + .setModeParameter("30").setIndex(1); + PastSnapshot vs3 = new PastSnapshot("version", DateUtils.parseDate("2008-12-13"), getSession().getSingleResult(Snapshot.class, "id", 300)) + .setModeParameter("1.2.3").setIndex(3); when(conf.getProjectPastSnapshots()).thenReturn(Arrays.asList(vs1, vs3)); Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1000); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java index 5af00f44226..f1444bd6acc 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java @@ -23,13 +23,13 @@ import org.apache.commons.configuration.PropertiesConfiguration; import org.junit.Test; import org.sonar.api.CoreProperties; import org.sonar.api.database.model.Snapshot; +import org.sonar.api.utils.DateUtils; import org.sonar.batch.components.PastSnapshot; import org.sonar.batch.components.PastSnapshotFinder; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.Date; import static org.hamcrest.CoreMatchers.is; @@ -55,8 +55,8 @@ public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase { public void shouldInitPastSnapshots() throws ParseException { PropertiesConfiguration conf = new PropertiesConfiguration(); PastSnapshotFinder pastSnapshotFinder = mock(PastSnapshotFinder.class); - when(pastSnapshotFinder.find(null, conf, 1)).thenReturn(new PastSnapshot("days", null, newSnapshot("2010-10-15"))); - when(pastSnapshotFinder.find(null, conf, 3)).thenReturn(new PastSnapshot("days", null, newSnapshot("2010-10-13"))); + when(pastSnapshotFinder.find(null, conf, 1)).thenReturn(new PastSnapshot("days", new Date(), newSnapshot("2010-10-15"))); + when(pastSnapshotFinder.find(null, conf, 3)).thenReturn(new PastSnapshot("days", new Date(), newSnapshot("2010-10-13"))); TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(conf, pastSnapshotFinder, null); @@ -68,9 +68,6 @@ public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase { } private Snapshot newSnapshot(String date) throws ParseException { - Date createdAt = new SimpleDateFormat("yyyy-MM-dd").parse(date); - return new Snapshot().setCreatedAt(createdAt); + return new Snapshot().setCreatedAt(DateUtils.parseDate(date)); } - - } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java index 12d95464637..242f6f94393 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java @@ -34,6 +34,7 @@ import org.sonar.batch.components.PastSnapshot; import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.util.Arrays; +import java.util.Date; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -61,8 +62,8 @@ public class VariationDecoratorTest extends AbstractDbUnitTestCase { Resource javaPackage = new JavaPackage("org.foo"); PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class); - PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Snapshot()).setIndex(1); - PastSnapshot pastSnapshot3 = new PastSnapshot("days", new Snapshot()).setIndex(3); + PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1); + PastSnapshot pastSnapshot3 = new PastSnapshot("days", new Date()).setIndex(3); // first past analysis when(pastMeasuresLoader.getPastMeasures(javaPackage, pastSnapshot1)).thenReturn(Arrays.asList( |