diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-02-03 12:20:09 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-02-04 15:12:54 +0100 |
commit | 217d3d5d39aa5a06828743d11b5a7fab0e10d8f0 (patch) | |
tree | b42df065d0e525642fca009503a7b96fa31e967e /plugins/sonar-core-plugin/src/test | |
parent | bb6f3ce801fecf9e7877a90a7134d8a691ccddd2 (diff) | |
download | sonarqube-217d3d5d39aa5a06828743d11b5a7fab0e10d8f0.tar.gz sonarqube-217d3d5d39aa5a06828743d11b5a7fab0e10d8f0.zip |
SONAR-6044 Stop storing distribution of issue-related measures by rule
Diffstat (limited to 'plugins/sonar-core-plugin/src/test')
-rw-r--r-- | plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java index be9b8ae586c..054f2b5f02f 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java @@ -39,7 +39,6 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; -import org.sonar.api.test.IsRuleMeasure; import org.sonar.batch.components.Period; import org.sonar.batch.components.TimeMachineConfiguration; @@ -186,39 +185,10 @@ public class CountUnresolvedIssuesDecoratorTest { } @Test - public void should_count_issues_per_rule() { - List<Issue> issues = newArrayList(); - issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setSeverity(RulePriority.CRITICAL.name())); - issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setSeverity(RulePriority.CRITICAL.name())); - issues.add(new DefaultIssue().setRuleKey(ruleA2.ruleKey()).setSeverity(RulePriority.MAJOR.name())); - when(issuable.issues()).thenReturn(issues); - - decorator.decorate(resource, context); - - verify(context).saveMeasure(argThat(new IsRuleMeasure(CoreMetrics.CRITICAL_VIOLATIONS, ruleA1, 2.0))); - verify(context, never()).saveMeasure(argThat(new IsRuleMeasure(CoreMetrics.MAJOR_VIOLATIONS, ruleA1, 0.0))); - verify(context).saveMeasure(argThat(new IsRuleMeasure(CoreMetrics.MAJOR_VIOLATIONS, ruleA2, 1.0))); - } - - @Test - public void same_rule_should_have_different_severities() { - List<Issue> issues = newArrayList(); - issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setSeverity(RulePriority.CRITICAL.name())); - issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setSeverity(RulePriority.CRITICAL.name())); - issues.add(new DefaultIssue().setRuleKey(ruleA1.ruleKey()).setSeverity(RulePriority.MINOR.name())); - when(issuable.issues()).thenReturn(issues); - - decorator.decorate(resource, context); - - verify(context).saveMeasure(argThat(new IsRuleMeasure(CoreMetrics.CRITICAL_VIOLATIONS, ruleA1, 2.0))); - verify(context).saveMeasure(argThat(new IsRuleMeasure(CoreMetrics.MINOR_VIOLATIONS, ruleA1, 1.0))); - } - - @Test public void should_count_issues_after_date() { List<Issue> issues = createIssuesForNewMetrics(); - assertThat(decorator.countIssuesAfterDate(null, fiveDaysAgo)).isEqualTo(0); + assertThat(decorator.countIssuesAfterDate(Collections.<Issue>emptyList(), fiveDaysAgo)).isEqualTo(0); assertThat(decorator.countIssuesAfterDate(issues, fiveDaysAgo)).isEqualTo(1); // 1 rightNow assertThat(decorator.countIssuesAfterDate(issues, tenDaysAgo)).isEqualTo(3); // 1 rightNow + 2 fiveDaysAgo assertThat(decorator.countIssuesAfterDate(issues, sameSecond)).isEqualTo(0); // 0 @@ -252,18 +222,6 @@ public class CountUnresolvedIssuesDecoratorTest { } @Test - public void should_save_rule_new_issues() { - when(issuable.issues()).thenReturn(createIssuesForNewMetrics()); - - decorator.decorate(resource, context); - - // remember : period1 is 5daysAgo, period2 is 10daysAgo - verify(context).saveMeasure(argThat(new IsVariationRuleMeasure(CoreMetrics.NEW_CRITICAL_VIOLATIONS, ruleA1, 1.0, 1.0))); - verify(context).saveMeasure(argThat(new IsVariationRuleMeasure(CoreMetrics.NEW_MAJOR_VIOLATIONS, ruleA2, 0.0, 1.0))); - verify(context).saveMeasure(argThat(new IsVariationRuleMeasure(CoreMetrics.NEW_MINOR_VIOLATIONS, ruleB1, 0.0, 1.0))); - } - - @Test public void should_not_save_new_issues_if_measure_already_computed() { when(context.getMeasure(CoreMetrics.NEW_VIOLATIONS)).thenReturn(new Measure()); when(issuable.issues()).thenReturn(createIssuesForNewMetrics()); |