aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java3
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/multi-modules-with-issues.xml10
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database.xml2
5 files changed, 21 insertions, 2 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java
index 10f5253ea68..c969d44ee6e 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java
@@ -30,11 +30,9 @@ import org.sonar.api.resources.Resource;
import org.sonar.api.resources.ResourceUtils;
import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.core.DryRunIncompatible;
import java.util.List;
-@DryRunIncompatible
@DependedUpon(DecoratorBarriers.END_OF_TIME_MACHINE)
public final class TimeMachineConfigurationPersister implements Decorator {
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java
index 0125142ce2b..baa3539bfe7 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java
@@ -106,6 +106,9 @@ public class DryRunDatabaseFactory implements ServerComponent {
projectQuery.append(" )");
template.copyTable(source, dest, "projects", projectQuery.toString());
+ template.copyTable(source, dest, "snapshots", "SELECT * FROM snapshots WHERE project_id=" + projectId);
+ template.copyTable(source, dest, "project_measures", "SELECT m.* FROM project_measures m INNER JOIN snapshots s on m.snapshot_id=s.id WHERE s.project_id=" + projectId);
+
String forRootModule = "root_component_id in (select id from projects where id=" + projectId + " and qualifier='TRK')";
String forSubModule = "component_id in (select id from projects where id=" + projectId + " or root_id=" + projectId + ")";
template.copyTable(source, dest, "issues", "SELECT * FROM issues WHERE ((" + forRootModule + ") OR ( " + forSubModule + ")) AND status <> '" + Issue.STATUS_CLOSED + "'");
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java
index 354ab2d0cf9..ce9f35f52fc 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java
@@ -81,6 +81,8 @@ public class DryRunDatabaseFactoryTest extends AbstractDaoTestCase {
assertThat(rowCount("metrics")).isEqualTo(2);
assertThat(rowCount("projects")).isEqualTo(1);
+ assertThat(rowCount("snapshots")).isEqualTo(1);
+ assertThat(rowCount("project_measures")).isEqualTo(1);
}
@Test
@@ -106,6 +108,8 @@ public class DryRunDatabaseFactoryTest extends AbstractDaoTestCase {
dataSource = createDatabase(database);
assertThat(rowCount("issues")).isEqualTo(1);
assertThat(rowCount("projects")).isEqualTo(4);
+ assertThat(rowCount("snapshots")).isEqualTo(1);
+ assertThat(rowCount("project_measures")).isEqualTo(2);
}
@Test
@@ -119,6 +123,8 @@ public class DryRunDatabaseFactoryTest extends AbstractDaoTestCase {
dataSource = createDatabase(database);
assertThat(rowCount("issues")).isEqualTo(1);
assertThat(rowCount("projects")).isEqualTo(2);
+ assertThat(rowCount("snapshots")).isEqualTo(1);
+ assertThat(rowCount("project_measures")).isEqualTo(2);
}
@Test
diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/multi-modules-with-issues.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/multi-modules-with-issues.xml
index a9cdf217f0c..af4cd1595c5 100644
--- a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/multi-modules-with-issues.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/multi-modules-with-issues.xml
@@ -36,6 +36,16 @@
<snapshots id="3002" project_id="302" root_project_id="300" root_snapshot_id="3000" path="3000." islast="[true]"/>
<snapshots id="3003" project_id="303" root_project_id="300" root_snapshot_id="3000" path="3000.3001." islast="[true]"/>
+ <project_measures id="1" value="12" metric_id="1" snapshot_id="3000" />
+ <project_measures id="2" value="5" metric_id="1" snapshot_id="3001" />
+ <project_measures id="3" value="7" metric_id="1" snapshot_id="3002" />
+ <project_measures id="4" value="5" metric_id="1" snapshot_id="3003" />
+ <project_measures id="5" value="35" metric_id="2" snapshot_id="3000" />
+ <project_measures id="6" value="20" metric_id="2" snapshot_id="3001" />
+ <project_measures id="7" value="30" metric_id="2" snapshot_id="3002" />
+ <project_measures id="8" value="20" metric_id="2" snapshot_id="3003" />
+
+
<rules id="500" plugin_rule_key="AvoidCycle" plugin_name="squid"/>
<rules id="501" plugin_rule_key="NullRef" plugin_name="squid"/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database.xml
index 1958f492aaa..2678396e998 100644
--- a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database.xml
@@ -23,4 +23,6 @@
<alerts id="1" profile_id="1" metric_id="1" operator="lt" value_error="5" value_warning="" period="[null]"/>
+ <project_measures id="1" value="10" metric_id="1" snapshot_id="1000" />
+
</dataset>