diff options
author | David Gageot <david@gageot.net> | 2012-07-09 10:16:32 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-07-09 12:45:31 +0200 |
commit | 111cf7219f5a4439687f2cd836fb8e498e545773 (patch) | |
tree | 3082b6db800dfde7397d0d5c639611e73ecba5a0 /sonar-batch/src | |
parent | 86e442b7124f1513d8beeb2f84860cb05502d3fb (diff) | |
download | sonarqube-111cf7219f5a4439687f2cd836fb8e498e545773.tar.gz sonarqube-111cf7219f5a4439687f2cd836fb8e498e545773.zip |
SONAR-3437 Prepare for refactoring to MyBatis
Diffstat (limited to 'sonar-batch/src')
7 files changed, 119 insertions, 280 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java index ddc1df16b7e..3b967d89e38 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java @@ -19,6 +19,7 @@ */ package org.sonar.batch.index; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.SetMultimap; import org.apache.commons.lang.math.NumberUtils; @@ -39,14 +40,12 @@ import java.util.Collection; import java.util.Map; public final class MeasurePersister { - + private final DatabaseSession session; + private final ResourcePersister resourcePersister; + private final RuleFinder ruleFinder; + private final MemoryOptimizer memoryOptimizer; + private final SetMultimap<Resource, Measure> unsavedMeasuresByResource = LinkedHashMultimap.create(); private boolean delayedMode = false; - private SetMultimap<Resource, Measure> unsavedMeasuresByResource = LinkedHashMultimap.create(); - private DatabaseSession session; - private ResourcePersister resourcePersister; - private RuleFinder ruleFinder; - private MemoryOptimizer memoryOptimizer; - public MeasurePersister(DatabaseSession session, ResourcePersister resourcePersister, RuleFinder ruleFinder, MemoryOptimizer memoryOptimizer) { this.session = session; @@ -60,29 +59,23 @@ public final class MeasurePersister { } public void saveMeasure(Resource resource, Measure measure) { - boolean saveLater = (measure.getPersistenceMode().useMemory() && delayedMode); - if (saveLater) { + if (shouldSaveLater(measure)) { unsavedMeasuresByResource.put(resource, measure); + return; + } - } else { + if (measure.getId() != null) { // update + MeasureModel model = session.reattach(MeasureModel.class, measure.getId()); + model = mergeModel(measure, model); + + model.save(session); + memoryOptimizer.evictDataMeasure(measure, model); + } else if (shouldPersistMeasure(resource, measure)) { // insert Snapshot snapshot = resourcePersister.getSnapshotOrFail(resource); - MeasureModel model = null; - if (measure.getId() != null) { - // update - model = session.reattach(MeasureModel.class, measure.getId()); - model = mergeModel(measure, model); - model.save(session); - - } else if (shouldPersistMeasure(resource, measure)) { - // insert - model = createModel(measure); - model.setSnapshotId(snapshot.getId()); - model.save(session); - measure.setId(model.getId()); // could be removed - } - if (model != null) { - memoryOptimizer.evictDataMeasure(measure, model); - } + MeasureModel model = createModel(measure).setSnapshotId(snapshot.getId()); + + model.save(session); + memoryOptimizer.evictDataMeasure(measure, model); } } @@ -90,39 +83,44 @@ public final class MeasurePersister { return memoryOptimizer.reloadMeasure(measure); } + private boolean shouldSaveLater(Measure measure) { + return delayedMode && measure.getPersistenceMode().useMemory(); + } + + @VisibleForTesting static boolean shouldPersistMeasure(Resource resource, Measure measure) { - Metric metric = measure.getMetric(); return measure.getPersistenceMode().useDatabase() && - !(ResourceUtils.isEntity(resource) && isBestValueMeasure(measure, metric)); + !(ResourceUtils.isEntity(resource) && isBestValueMeasure(measure, measure.getMetric())); } + @VisibleForTesting static boolean isBestValueMeasure(Measure measure, Metric metric) { - return measure.getId() == null && - metric.isOptimizedBestValue() == Boolean.TRUE && - metric.getBestValue() != null && - (measure.getValue() == null || NumberUtils.compare(metric.getBestValue(), measure.getValue()) == 0) && - measure.getAlertStatus() == null && - measure.getDescription() == null && - measure.getTendency() == null && - measure.getUrl() == null && - !measure.hasData() && - (measure.getVariation1() == null || NumberUtils.compare(measure.getVariation1().doubleValue(), 0.0) == 0) && - (measure.getVariation2() == null || NumberUtils.compare(measure.getVariation2().doubleValue(), 0.0) == 0) && - (measure.getVariation3() == null || NumberUtils.compare(measure.getVariation3().doubleValue(), 0.0) == 0) && - (measure.getVariation4() == null || NumberUtils.compare(measure.getVariation4().doubleValue(), 0.0) == 0) && - (measure.getVariation5() == null || NumberUtils.compare(measure.getVariation5().doubleValue(), 0.0) == 0); + return measure.getId() == null + && metric.isOptimizedBestValue() == Boolean.TRUE + && metric.getBestValue() != null + && (measure.getValue() == null || NumberUtils.compare(metric.getBestValue(), measure.getValue()) == 0) + && measure.getAlertStatus() == null + && measure.getDescription() == null + && measure.getTendency() == null + && measure.getUrl() == null + && !measure.hasData() + && (measure.getVariation1() == null || NumberUtils.compare(measure.getVariation1().doubleValue(), 0.0) == 0) + && (measure.getVariation2() == null || NumberUtils.compare(measure.getVariation2().doubleValue(), 0.0) == 0) + && (measure.getVariation3() == null || NumberUtils.compare(measure.getVariation3().doubleValue(), 0.0) == 0) + && (measure.getVariation4() == null || NumberUtils.compare(measure.getVariation4().doubleValue(), 0.0) == 0) + && (measure.getVariation5() == null || NumberUtils.compare(measure.getVariation5().doubleValue(), 0.0) == 0); } public void dump() { LoggerFactory.getLogger(getClass()).debug("{} measures to dump", unsavedMeasuresByResource.size()); + Map<Resource, Collection<Measure>> map = unsavedMeasuresByResource.asMap(); for (Map.Entry<Resource, Collection<Measure>> entry : map.entrySet()) { Resource resource = entry.getKey(); Snapshot snapshot = resourcePersister.getSnapshot(entry.getKey()); for (Measure measure : entry.getValue()) { if (shouldPersistMeasure(resource, measure)) { - MeasureModel model = createModel(measure); - model.setSnapshotId(snapshot.getId()); + MeasureModel model = createModel(measure).setSnapshotId(snapshot.getId()); model.save(session); } } @@ -132,12 +130,12 @@ public final class MeasurePersister { unsavedMeasuresByResource.clear(); } - MeasureModel createModel(Measure measure) { + private MeasureModel createModel(Measure measure) { return mergeModel(measure, new MeasureModel()); } - MeasureModel mergeModel(Measure measure, MeasureModel merge) { - merge.setMetricId(measure.getMetric().getId());// we assume that the index has updated the metric + private MeasureModel mergeModel(Measure measure, MeasureModel merge) { + merge.setMetricId(measure.getMetric().getId()); // we assume that the index has updated the metric merge.setDescription(measure.getDescription()); merge.setData(measure.getData()); merge.setAlertStatus(measure.getAlertStatus()); @@ -161,11 +159,10 @@ public final class MeasurePersister { merge.setRulePriority(ruleMeasure.getSeverity()); if (ruleMeasure.getRule() != null) { Rule ruleWithId = ruleFinder.findByKey(ruleMeasure.getRule().getRepositoryKey(), ruleMeasure.getRule().getKey()); - if (ruleWithId != null) { - merge.setRuleId(ruleWithId.getId()); - } else { + if (ruleWithId == null) { throw new SonarException("Can not save a measure with unknown rule " + ruleMeasure); } + merge.setRuleId(ruleWithId.getId()); } } return merge; diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java index b37166c3d94..4d13104ba42 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java @@ -30,16 +30,16 @@ import org.sonar.api.measures.PersistenceMode; import org.sonar.api.resources.JavaFile; import org.sonar.api.resources.JavaPackage; import org.sonar.api.resources.Project; -import org.sonar.core.rule.DefaultRuleFinder; import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyObject; +import static org.fest.assertions.Assertions.assertThat; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class MeasurePersisterTest extends AbstractDbUnitTestCase { @@ -48,38 +48,29 @@ public class MeasurePersisterTest extends AbstractDbUnitTestCase { public static final int FILE_SNAPSHOT_ID = 3003; public static final int COVERAGE_METRIC_ID = 2; - private ResourcePersister resourcePersister; private MeasurePersister measurePersister; + private ResourcePersister resourcePersister = mock(ResourcePersister.class); + private MemoryOptimizer memoryOptimizer = mock(MemoryOptimizer.class); private Project project = new Project("foo"); private JavaPackage aPackage = new JavaPackage("org.foo"); private JavaFile aFile = new JavaFile("org.foo.Bar"); - private Snapshot projectSnapshot, packageSnapshot, fileSnapshot; - private Metric ncloc, coverage; - private MemoryOptimizer memoryOptimizer; + private Snapshot projectSnapshot = snapshot(PROJECT_SNAPSHOT_ID); + private Snapshot packageSnapshot = snapshot(PACKAGE_SNAPSHOT_ID); @Before public void mockResourcePersister() { - setupData("shared"); - resourcePersister = mock(ResourcePersister.class); - projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", PROJECT_SNAPSHOT_ID); - packageSnapshot = getSession().getSingleResult(Snapshot.class, "id", PACKAGE_SNAPSHOT_ID); - fileSnapshot = getSession().getSingleResult(Snapshot.class, "id", FILE_SNAPSHOT_ID); - ncloc = getSession().getSingleResult(Metric.class, "key", "ncloc"); - coverage = getSession().getSingleResult(Metric.class, "key", "coverage"); - when(resourcePersister.getSnapshotOrFail(eq(project))).thenReturn(projectSnapshot); - when(resourcePersister.getSnapshotOrFail(eq(aPackage))).thenReturn(packageSnapshot); - when(resourcePersister.getSnapshotOrFail(eq(aFile))).thenReturn(fileSnapshot); + when(resourcePersister.getSnapshotOrFail(project)).thenReturn(projectSnapshot); when(resourcePersister.getSnapshot(project)).thenReturn(projectSnapshot); when(resourcePersister.getSnapshot(aPackage)).thenReturn(packageSnapshot); - when(resourcePersister.getSnapshot(aFile)).thenReturn(fileSnapshot); - memoryOptimizer = mock(MemoryOptimizer.class); - measurePersister = new MeasurePersister(getSession(), resourcePersister, new DefaultRuleFinder(getSessionFactory()), memoryOptimizer); + + measurePersister = new MeasurePersister(getSession(), resourcePersister, null, memoryOptimizer); } @Test public void shouldInsertMeasure() { - Measure measure = new Measure(ncloc).setValue(1234.0); + setupData("shared"); + Measure measure = new Measure(ncloc()).setValue(1234.0); measurePersister.saveMeasure(project, measure); checkTables("shouldInsertMeasure", "project_measures"); @@ -87,19 +78,17 @@ public class MeasurePersisterTest extends AbstractDbUnitTestCase { @Test public void shouldRegisterPersistedMeasureToMemoryOptimizer() { - Measure measure = new Measure(ncloc).setValue(1234.0); - + Measure measure = new Measure(ncloc()).setValue(1234.0); measurePersister.saveMeasure(project, measure); - verify(memoryOptimizer).evictDataMeasure(eq(measure), (MeasureModel)anyObject()); + verify(memoryOptimizer).evictDataMeasure(eq(measure), any(MeasureModel.class)); } - @Test public void shouldUpdateMeasure() { - Measure measure = new Measure(coverage).setValue(12.5); - measure.setId(1L); + setupData("shared"); + Measure measure = new Measure(coverage()).setValue(12.5).setId(1L); measurePersister.saveMeasure(project, measure); checkTables("shouldUpdateMeasure", "project_measures"); @@ -107,28 +96,28 @@ public class MeasurePersisterTest extends AbstractDbUnitTestCase { @Test public void shouldAddDelayedMeasureSeveralTimes() { + Measure measure = new Measure(ncloc()).setValue(200.0); + measurePersister.setDelayedMode(true); - Measure measure = new Measure(ncloc).setValue(200.0); measurePersister.saveMeasure(project, measure); measure.setValue(300.0); measurePersister.saveMeasure(project, measure); - measurePersister.dump(); List<MeasureModel> coverageMeasures = getSession().getResults(MeasureModel.class, "snapshotId", PROJECT_SNAPSHOT_ID, "metricId", 1); - assertThat(coverageMeasures.size(), is(1)); - assertThat(coverageMeasures.get(0).getValue(), is(300.0)); + assertThat(coverageMeasures).onProperty("value").containsExactly(300.0); } @Test public void shouldDelaySaving() { - measurePersister.setDelayedMode(true); + setupData("shared"); - measurePersister.saveMeasure(project, new Measure(ncloc).setValue(1234.0)); - measurePersister.saveMeasure(aPackage, new Measure(ncloc).setValue(50.0)); + measurePersister.setDelayedMode(true); + measurePersister.saveMeasure(project, new Measure(ncloc()).setValue(1234.0)); + measurePersister.saveMeasure(aPackage, new Measure(ncloc()).setValue(50.0)); - assertThat(getSession().getResults(MeasureModel.class, "metricId", 1).size(), is(0)); + assertThat(getSession().getResults(MeasureModel.class, "metricId", 1)).isEmpty(); measurePersister.dump(); checkTables("shouldDelaySaving", "project_measures"); @@ -136,80 +125,92 @@ public class MeasurePersisterTest extends AbstractDbUnitTestCase { @Test public void shouldNotDelaySavingWithDatabaseOnlyMeasure() { - measurePersister.setDelayedMode(true); - - measurePersister.saveMeasure(project, new Measure(ncloc).setValue(1234.0).setPersistenceMode(PersistenceMode.DATABASE)); // database only - measurePersister.saveMeasure(aPackage, new Measure(ncloc).setValue(50.0)); // database + memory + setupData("shared"); - // no dump => the db-only measure is saved + measurePersister.setDelayedMode(true); + measurePersister.saveMeasure(project, new Measure(ncloc()).setValue(1234.0).setPersistenceMode(PersistenceMode.DATABASE)); // database + measurePersister.saveMeasure(aPackage, new Measure(ncloc()).setValue(50.0)); // database + memory checkTables("shouldNotDelaySavingWithDatabaseOnlyMeasure", "project_measures"); } @Test public void shouldNotSaveBestValues() { - JavaFile file = new JavaFile("org.foo.MyClass"); - - Measure measure = new Measure(coverage).setValue(0.0); - assertThat(MeasurePersister.shouldPersistMeasure(file, measure), is(true)); + Measure measure = new Measure(coverage()).setValue(0.0); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, measure)).isTrue(); - measure = new Measure(coverage).setValue(75.8); - assertThat(MeasurePersister.shouldPersistMeasure(file, measure), is(true)); + measure = new Measure(coverage()).setValue(75.8); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, measure)).isTrue(); - measure = new Measure(coverage).setValue(100.0); - assertThat(MeasurePersister.shouldPersistMeasure(file, measure), is(false)); + measure = new Measure(coverage()).setValue(100.0); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, measure)).isFalse(); } @Test public void shouldNotSaveBestValueMeasuresInDelayedMode() { measurePersister.setDelayedMode(true); + measurePersister.saveMeasure(aFile, new Measure(coverage()).setValue(100.0)); - measurePersister.saveMeasure(aFile, new Measure(coverage).setValue(100.0)); - - assertThat(getSession().getResults(MeasureModel.class, "metricId", COVERAGE_METRIC_ID, "snapshotId", FILE_SNAPSHOT_ID).size(), is(0)); + assertThat(getSession().getResults(MeasureModel.class, "metricId", COVERAGE_METRIC_ID, "snapshotId", FILE_SNAPSHOT_ID)).isEmpty(); measurePersister.dump(); - // not saved because it's a best value measure - assertThat(getSession().getResults(MeasureModel.class, "metricId", COVERAGE_METRIC_ID, "snapshotId", FILE_SNAPSHOT_ID).size(), is(0)); + assertThat(getSession().getResults(MeasureModel.class, "metricId", COVERAGE_METRIC_ID, "snapshotId", FILE_SNAPSHOT_ID)).isEmpty(); } - @Test public void shouldNotSaveMemoryOnlyMeasures() { Measure measure = new Measure("ncloc").setPersistenceMode(PersistenceMode.MEMORY); - assertThat(MeasurePersister.shouldPersistMeasure(aPackage, measure), is(false)); + assertThat(MeasurePersister.shouldPersistMeasure(aPackage, measure)).isFalse(); } @Test public void shouldAlwaysPersistNonFileMeasures() { - assertThat(MeasurePersister.shouldPersistMeasure(project, new Measure(CoreMetrics.LINES, 200.0)), is(true)); - assertThat(MeasurePersister.shouldPersistMeasure(aPackage, new Measure(CoreMetrics.LINES, 200.0)), is(true)); + assertThat(MeasurePersister.shouldPersistMeasure(project, new Measure(CoreMetrics.LINES, 200.0))).isTrue(); + assertThat(MeasurePersister.shouldPersistMeasure(aPackage, new Measure(CoreMetrics.LINES, 200.0))).isTrue(); } @Test public void shouldNotPersistSomeFileMeasuresWithBestValue() { - JavaFile file = new JavaFile("org.foo.Bar"); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, new Measure(CoreMetrics.LINES, 200.0))).isTrue(); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, new Measure(CoreMetrics.DUPLICATED_LINES_DENSITY, 3.0))).isTrue(); - // must persist: - assertThat(MeasurePersister.shouldPersistMeasure(file, new Measure(CoreMetrics.LINES, 200.0)), is(true)); - assertThat(MeasurePersister.shouldPersistMeasure(file, new Measure(CoreMetrics.DUPLICATED_LINES_DENSITY, 3.0)), is(true)); - - - // must not persist: Measure duplicatedLines = new Measure(CoreMetrics.DUPLICATED_LINES_DENSITY, 0.0); - assertThat(MeasurePersister.shouldPersistMeasure(file, duplicatedLines), is(false)); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, duplicatedLines)).isFalse(); duplicatedLines.setVariation1(0.0); - assertThat(MeasurePersister.shouldPersistMeasure(file, duplicatedLines), is(false)); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, duplicatedLines)).isFalse(); duplicatedLines.setVariation1(-3.0); - assertThat(MeasurePersister.shouldPersistMeasure(file, duplicatedLines), is(true)); + assertThat(MeasurePersister.shouldPersistMeasure(aFile, duplicatedLines)).isTrue(); } @Test public void nullValueAndNullVariationsShouldBeConsideredAsBestValue() { Measure measure = new Measure(CoreMetrics.NEW_VIOLATIONS_KEY); - assertThat(MeasurePersister.isBestValueMeasure(measure, CoreMetrics.NEW_VIOLATIONS), is(true)); + + assertThat(MeasurePersister.isBestValueMeasure(measure, CoreMetrics.NEW_VIOLATIONS)).isTrue(); + } + + private static Snapshot snapshot(int id) { + Snapshot snapshot = mock(Snapshot.class); + when(snapshot.getId()).thenReturn(id); + return snapshot; + } + + private static Metric ncloc() { + Metric ncloc = mock(Metric.class); + when(ncloc.getId()).thenReturn(1); + when(ncloc.getKey()).thenReturn("ncloc"); + return ncloc; + } + + private static Metric coverage() { + Metric coverage = mock(Metric.class); + when(coverage.getId()).thenReturn(COVERAGE_METRIC_ID); + when(coverage.getKey()).thenReturn("coverage"); + when(coverage.isOptimizedBestValue()).thenReturn(true); + when(coverage.getBestValue()).thenReturn(100.0); + return coverage; } } diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml index 2b8c2b91a70..f8900a3e228 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml @@ -1,35 +1,5 @@ <dataset> - <metrics delete_historical_data="[null]" id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/> - <metrics delete_historical_data="[null]" id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/> - - <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" - name="project name" long_name="project name" description="project description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001" - name="org.foo" long_name="org.foo" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1003" scope="FIL" qualifier="CLA" kee="foo:org.foo.Bar" root_id="1001" - name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" - scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" - status="U" islast="false" depth="0" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3002" project_id="1002" parent_snapshot_id="3001" root_project_id="1001" root_snapshot_id="3001" - scope="DIR" qualifier="PAC" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001." - status="U" islast="false" depth="1" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3003" project_id="1003" parent_snapshot_id="3002" root_project_id="1001" root_snapshot_id="3001" - scope="FIL" qualifier="CLA" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001.3002." - status="U" islast="false" depth="2" /> - - <project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]" RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml index b6f2c36971e..f0ac513c87d 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml @@ -1,35 +1,5 @@ <dataset> - <metrics delete_historical_data="[null]" id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" - hidden="false"/> - <metrics delete_historical_data="[null]" id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/> - - <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" - name="project name" long_name="project name" description="project description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001" - name="org.foo" long_name="org.foo" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1003" scope="FIL" qualifier="CLA" kee="foo:org.foo.Bar" root_id="1001" - name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" - scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" - status="U" islast="false" depth="0" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3002" project_id="1002" parent_snapshot_id="3001" root_project_id="1001" root_snapshot_id="3001" - scope="DIR" qualifier="PAC" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001." - status="U" islast="false" depth="1" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3003" project_id="1003" parent_snapshot_id="3002" root_project_id="1001" root_snapshot_id="3001" - scope="FIL" qualifier="CLA" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001.3002." - status="U" islast="false" depth="2" /> - <project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]" RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]" @@ -49,5 +19,4 @@ person_id="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/> - </dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml index 933b0fff827..1cd6e6d10c4 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml @@ -1,35 +1,5 @@ <dataset> - <metrics delete_historical_data="[null]" id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/> - - <metrics delete_historical_data="[null]" id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/> - - <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" - name="project name" long_name="project name" description="project description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001" - name="org.foo" long_name="org.foo" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1003" scope="FIL" qualifier="CLA" kee="foo:org.foo.Bar" root_id="1001" - name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" - scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" - status="U" islast="false" depth="0" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3002" project_id="1002" parent_snapshot_id="3001" root_project_id="1001" root_snapshot_id="3001" - scope="DIR" qualifier="PAC" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001." - status="U" islast="false" depth="1" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3003" project_id="1003" parent_snapshot_id="3002" root_project_id="1001" root_snapshot_id="3001" - scope="FIL" qualifier="CLA" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001.3002." - status="U" islast="false" depth="2" /> - <project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]" RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml index edc7e905a03..1cd6e6d10c4 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml @@ -1,35 +1,5 @@ <dataset> - <metrics delete_historical_data="[null]" id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/> - - <metrics delete_historical_data="[null]" id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/> - - <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" - name="project name" long_name="project name" description="project description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001" - name="org.foo" long_name="org.foo" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1003" scope="FIL" qualifier="CLA" kee="foo:org.foo.Bar" root_id="1001" - name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" - scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" - status="U" islast="false" depth="0" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3002" project_id="1002" parent_snapshot_id="3001" root_project_id="1001" root_snapshot_id="3001" - scope="DIR" qualifier="PAC" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001." - status="U" islast="false" depth="1" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3003" project_id="1003" parent_snapshot_id="3002" root_project_id="1001" root_snapshot_id="3001" - scope="FIL" qualifier="CLA" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001.3002." - status="U" islast="false" depth="2" /> - <project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]" RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]" @@ -42,12 +12,4 @@ person_id="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/> - <!-- delayed --> - <!--<project_measures id="3" VALUE="50.0" METRIC_ID="1" SNAPSHOT_ID="3002" alert_text="[null]" RULES_CATEGORY_ID="[null]"--> - <!--RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"--> - <!--alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"--> - <!--person_id="[null]"--> - <!--variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>--> - - </dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml index 4758f158973..f4742847f20 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml @@ -1,35 +1,5 @@ <dataset> - <metrics delete_historical_data="[null]" id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/> - - <metrics delete_historical_data="[null]" id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="true" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/> - - <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" - name="project name" long_name="project name" description="project description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001" - name="org.foo" long_name="org.foo" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <projects id="1003" scope="FIL" qualifier="CLA" kee="foo:org.foo.Bar" root_id="1001" - name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" - scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" - status="U" islast="false" depth="0" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3002" project_id="1002" parent_snapshot_id="3001" root_project_id="1001" root_snapshot_id="3001" - scope="DIR" qualifier="PAC" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001." - status="U" islast="false" depth="1" /> - - <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3003" project_id="1003" parent_snapshot_id="3002" root_project_id="1001" root_snapshot_id="3001" - scope="FIL" qualifier="CLA" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="3001.3002." - status="U" islast="false" depth="2" /> - <project_measures id="1" VALUE="12.5" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]" RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]" |