From 7b301db8c7e3000ff2a04fce5534e45e7d973a1f Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 25 Apr 2014 11:17:09 +0200 Subject: Revert "SONAR-3437, SONAR-5189 Store measures in a persistit cache" This reverts commit 46395126b184c343df5471a147cdb48133f59f6f. --- .../sonar/api/measures/MeasuresFiltersTest.java | 46 ++++++++++------------ .../java/org/sonar/api/test/IsRuleMeasure.java | 2 +- 2 files changed, 22 insertions(+), 26 deletions(-) (limited to 'sonar-plugin-api/src/test/java/org/sonar') diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java index ea075ed2a99..f9f569f199b 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasuresFiltersTest.java @@ -25,7 +25,6 @@ import org.sonar.api.rules.RulePriority; import java.util.Arrays; import java.util.Collection; -import java.util.Iterator; import java.util.List; import static org.hamcrest.core.Is.is; @@ -38,8 +37,8 @@ public class MeasuresFiltersTest { MeasuresFilter filter = MeasuresFilters.metric(CoreMetrics.VIOLATIONS); Collection measures = Arrays.asList( - RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 50.0), - new Measure(CoreMetrics.VIOLATIONS, 500.0)); + RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 50.0), + new Measure(CoreMetrics.VIOLATIONS, 500.0)); assertThat(filter.filter(measures).getValue(), is(500.0)); } @@ -47,13 +46,10 @@ public class MeasuresFiltersTest { @Test public void all() { Collection measures = Arrays.asList( - RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 50.0), - new Measure(CoreMetrics.VIOLATIONS, 500.0)); + RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 50.0), + new Measure(CoreMetrics.VIOLATIONS, 500.0)); - Iterator filteredMeasures = MeasuresFilters.all().filter(measures).iterator(); - filteredMeasures.next(); - filteredMeasures.next(); - assertThat(filteredMeasures.hasNext(), is(false)); + assertThat(MeasuresFilters.all().filter(measures).size(), is(2)); } @Test @@ -62,13 +58,13 @@ public class MeasuresFiltersTest { Rule rule2 = new Rule("pmd", "key2"); MeasuresFilter filter = MeasuresFilters.rule(CoreMetrics.VIOLATIONS, rule1); List measures = Arrays.asList( - RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule1, 50.0), - RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule2, 10.0), - RuleMeasure.createForRule(CoreMetrics.VIOLATIONS_DENSITY, rule2, 3.3), + RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule1, 50.0), + RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule2, 10.0), + RuleMeasure.createForRule(CoreMetrics.VIOLATIONS_DENSITY, rule2, 3.3), - RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 400.0), - RuleMeasure.createForPriority(CoreMetrics.COVERAGE, RulePriority.CRITICAL, 400.0), - new Measure(CoreMetrics.VIOLATIONS, 500.0)); + RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 400.0), + RuleMeasure.createForPriority(CoreMetrics.COVERAGE, RulePriority.CRITICAL, 400.0), + new Measure(CoreMetrics.VIOLATIONS, 500.0)); assertThat(filter.filter(measures).getValue(), is(50.0)); } @@ -79,13 +75,13 @@ public class MeasuresFiltersTest { Rule rule2 = new Rule("pmd", "key2"); MeasuresFilter> filter = MeasuresFilters.rules(CoreMetrics.VIOLATIONS); List measures = Arrays.asList( - RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule1, 50.0), - RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule2, 10.0), - RuleMeasure.createForRule(CoreMetrics.VIOLATIONS_DENSITY, rule2, 3.3), + RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule1, 50.0), + RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, rule2, 10.0), + RuleMeasure.createForRule(CoreMetrics.VIOLATIONS_DENSITY, rule2, 3.3), - RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 400.0), - RuleMeasure.createForPriority(CoreMetrics.COVERAGE, RulePriority.CRITICAL, 400.0), - new Measure(CoreMetrics.VIOLATIONS, 500.0)); + RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 400.0), + RuleMeasure.createForPriority(CoreMetrics.COVERAGE, RulePriority.CRITICAL, 400.0), + new Measure(CoreMetrics.VIOLATIONS, 500.0)); assertThat(filter.filter(measures).size(), is(2)); } @@ -94,10 +90,10 @@ public class MeasuresFiltersTest { public void measure() { MeasuresFilter filter = MeasuresFilters.measure(new Measure(CoreMetrics.VIOLATIONS)); List measures = Arrays.asList( - new Measure(CoreMetrics.COMMENT_LINES, 50.0), - new Measure(CoreMetrics.VIOLATIONS, 10.0), - RuleMeasure.createForCategory(CoreMetrics.VIOLATIONS, 2, 12.0), - new Measure(CoreMetrics.COVERAGE, 15.0)); + new Measure(CoreMetrics.COMMENT_LINES, 50.0), + new Measure(CoreMetrics.VIOLATIONS, 10.0), + RuleMeasure.createForCategory(CoreMetrics.VIOLATIONS, 2, 12.0), + new Measure(CoreMetrics.COVERAGE, 15.0)); assertThat(filter.filter(measures).getValue(), is(10.0)); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java index 3f9f67ce236..091d8c781cd 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java @@ -46,7 +46,7 @@ public class IsRuleMeasure extends ArgumentMatcher { } RuleMeasure m = (RuleMeasure) o; return ObjectUtils.equals(metric, m.getMetric()) && - ObjectUtils.equals(rule.ruleKey(), m.ruleKey()) && + ObjectUtils.equals(rule, m.getRule()) && NumberUtils.compare(value, m.getValue()) == 0; } } -- cgit v1.2.3