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 {
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 + "'");
assertThat(rowCount("metrics")).isEqualTo(2);
assertThat(rowCount("projects")).isEqualTo(1);
+ assertThat(rowCount("snapshots")).isEqualTo(1);
+ assertThat(rowCount("project_measures")).isEqualTo(1);
}
@Test
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
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
<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"/>
<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>