diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-02 17:30:50 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-02 17:43:27 +0200 |
commit | 7757e395dd73233d752f15a039c580da0a52c3a0 (patch) | |
tree | 8ccfe725d6bcbe573d9f08efdf8d245f4365bc4c /sonar-batch/src | |
parent | 3285730cb7271b31c0d557830b7096808b3a47ec (diff) | |
download | sonarqube-7757e395dd73233d752f15a039c580da0a52c3a0.tar.gz sonarqube-7757e395dd73233d752f15a039c580da0a52c3a0.zip |
Revert "SONAR-6605 Replace some batch formulas by compute formulas"
This reverts commit 2f948758eebec934beb54701792cf2d558319251.
Diffstat (limited to 'sonar-batch/src')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java | 2 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java | 27 |
2 files changed, 27 insertions, 2 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java index 87d124989ed..b46febe1ab5 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java @@ -65,7 +65,7 @@ public class MeasuresMediumTest { .newScanTask(new File(projectDir, "sonar-project.properties")) .start(); - assertThat(result.allMeasures()).hasSize(63); + assertThat(result.allMeasures()).hasSize(69); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java b/sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java index d62fd760616..b03d9baf3bd 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java @@ -39,13 +39,14 @@ import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; import org.sonar.api.config.Settings; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; +import org.sonar.api.measures.PersistenceMode; import org.sonar.api.resources.File; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.rule.RuleKey; import org.sonar.batch.duplication.DuplicationCache; -import org.sonar.batch.index.BatchComponentCache; import org.sonar.batch.index.DefaultIndex; +import org.sonar.batch.index.BatchComponentCache; import org.sonar.batch.issue.ModuleIssues; import org.sonar.batch.report.ReportPublisher; import org.sonar.batch.sensor.coverage.CoverageExclusions; @@ -125,6 +126,30 @@ public class DefaultSensorStorageTest { } @Test + public void shouldSetAppropriatePersistenceMode() { + // Metric FUNCTION_COMPLEXITY_DISTRIBUTION is only persisted on directories. + + InputFile file = new DefaultInputFile("foo", "src/Foo.php"); + + ArgumentCaptor<org.sonar.api.measures.Measure> argumentCaptor = ArgumentCaptor.forClass(org.sonar.api.measures.Measure.class); + Resource sonarFile = File.create("src/Foo.php").setEffectiveKey("foo:src/Foo.php"); + resourceCache.add(sonarFile, null).setInputPath(file); + + when(sonarIndex.addMeasure(eq(sonarFile), argumentCaptor.capture())).thenReturn(null); + + sensorStorage.store(new DefaultMeasure() + .onFile(file) + .forMetric(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION) + .withValue("foo")); + + org.sonar.api.measures.Measure m = argumentCaptor.getValue(); + assertThat(m.getData()).isEqualTo("foo"); + assertThat(m.getMetric()).isEqualTo(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION); + assertThat(m.getPersistenceMode()).isEqualTo(PersistenceMode.MEMORY); + + } + + @Test public void shouldSaveProjectMeasureToSensorContext() { ArgumentCaptor<org.sonar.api.measures.Measure> argumentCaptor = ArgumentCaptor.forClass(org.sonar.api.measures.Measure.class); |