diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2012-12-04 11:59:12 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2012-12-04 11:59:12 +0100 |
commit | 034013c4aefee3ffbf158caf1489d261ae5bf4b9 (patch) | |
tree | 73f6e5a485e4a0498439567f31ae5b0ae08eb082 /sonar-batch/src | |
parent | a0b9f5612d661375fc6fa8e8c97a9b0a5dcd7ff7 (diff) | |
download | sonarqube-034013c4aefee3ffbf158caf1489d261ae5bf4b9.tar.gz sonarqube-034013c4aefee3ffbf158caf1489d261ae5bf4b9.zip |
SONARIDE-334 Title is not displayed for some rules
RuleI18nManager has now a new method to get the rule name by searching the name in the i18n, and then if not found return the rule name property.
Diffstat (limited to 'sonar-batch/src')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/local/DryRunExporter.java | 2 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/local/DryRunExporterTest.java | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/local/DryRunExporter.java b/sonar-batch/src/main/java/org/sonar/batch/local/DryRunExporter.java index 4edb28f633a..6f478c2fda7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/local/DryRunExporter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/local/DryRunExporter.java @@ -133,7 +133,7 @@ public class DryRunExporter implements BatchComponent { } private String name(Rule rule) { - return ruleI18nManager.getName(rule.getRepositoryKey(), rule.getKey(), Locale.getDefault()); + return ruleI18nManager.getName(rule, Locale.getDefault()); } @VisibleForTesting diff --git a/sonar-batch/src/test/java/org/sonar/batch/local/DryRunExporterTest.java b/sonar-batch/src/test/java/org/sonar/batch/local/DryRunExporterTest.java index c434b09afb3..a2a6ce5dc71 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/local/DryRunExporterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/local/DryRunExporterTest.java @@ -80,13 +80,15 @@ public class DryRunExporterTest { @Test public void should_export_violations() { + Rule rule = Rule.create("pmd", "RULE_KEY"); + when(server.getVersion()).thenReturn("3.4"); when(violation.getResource()).thenReturn(resource); when(violation.getLineId()).thenReturn(1); when(violation.getMessage()).thenReturn("VIOLATION"); - when(violation.getRule()).thenReturn(Rule.create("pmd", "RULE_KEY")); + when(violation.getRule()).thenReturn(rule); when(violation.getSeverity()).thenReturn(RulePriority.INFO); - when(ruleI18nManager.getName("pmd", "RULE_KEY", Locale.getDefault())).thenReturn("RULE_NAME"); + when(ruleI18nManager.getName(rule, Locale.getDefault())).thenReturn("RULE_NAME"); doReturn(Arrays.asList(violation)).when(dryRunExporter).getViolations(resource); StringWriter output = new StringWriter(); @@ -100,13 +102,15 @@ public class DryRunExporterTest { @Test public void should_export_violation_with_no_line() { + Rule rule = Rule.create("pmd", "RULE_KEY"); + when(server.getVersion()).thenReturn("3.4"); when(violation.getResource()).thenReturn(resource); when(violation.getLineId()).thenReturn(null); when(violation.getMessage()).thenReturn("VIOLATION"); - when(violation.getRule()).thenReturn(Rule.create("pmd", "RULE_KEY")); + when(violation.getRule()).thenReturn(rule); when(violation.getSeverity()).thenReturn(RulePriority.INFO); - when(ruleI18nManager.getName("pmd", "RULE_KEY", Locale.getDefault())).thenReturn("RULE_NAME"); + when(ruleI18nManager.getName(rule, Locale.getDefault())).thenReturn("RULE_NAME"); doReturn(Arrays.asList(violation)).when(dryRunExporter).getViolations(resource); StringWriter output = new StringWriter(); |