summaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-12-11 18:49:39 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-12-11 18:49:49 +0100
commitac7d7da73c1166afd909fa27142aa6960d2468b0 (patch)
tree2bbd46b97fa6e35cce04a873b5282f1dd76106ba /sonar-batch
parentf4d407defe92813659b24556f5d0a959f7522205 (diff)
downloadsonarqube-ac7d7da73c1166afd909fa27142aa6960d2468b0.tar.gz
sonarqube-ac7d7da73c1166afd909fa27142aa6960d2468b0.zip
SONAR-4688 remove remaining call to l10n bundle
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/JsonReport.java15
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java18
2 files changed, 18 insertions, 15 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JsonReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JsonReport.java
index c6f9bf8530a..992fb82ae91 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JsonReport.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JsonReport.java
@@ -29,6 +29,8 @@ import org.sonar.api.config.Settings;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.platform.Server;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleFinder;
import org.sonar.api.scan.filesystem.ModuleFileSystem;
import org.sonar.api.user.User;
import org.sonar.api.user.UserFinder;
@@ -62,25 +64,25 @@ public class JsonReport implements BatchComponent {
private final Settings settings;
private final ModuleFileSystem fileSystem;
private final Server server;
- private final RuleI18nManager ruleI18nManager;
+ private final RuleFinder ruleFinder;
private final IssueCache issueCache;
private final EventBus eventBus;
private final ComponentSelector componentSelector;
private AnalysisMode analysisMode;
private UserFinder userFinder;
- public JsonReport(Settings settings, ModuleFileSystem fileSystem, Server server, RuleI18nManager ruleI18nManager, IssueCache issueCache,
+ public JsonReport(Settings settings, ModuleFileSystem fileSystem, Server server, RuleFinder ruleFinder, IssueCache issueCache,
EventBus eventBus, ComponentSelectorFactory componentSelectorFactory, AnalysisMode mode, UserFinder userFinder) {
- this(settings, fileSystem, server, ruleI18nManager, issueCache, eventBus, componentSelectorFactory.create(), mode, userFinder);
+ this(settings, fileSystem, server, ruleFinder, issueCache, eventBus, componentSelectorFactory.create(), mode, userFinder);
}
@VisibleForTesting
- JsonReport(Settings settings, ModuleFileSystem fileSystem, Server server, RuleI18nManager ruleI18nManager, IssueCache issueCache,
+ JsonReport(Settings settings, ModuleFileSystem fileSystem, Server server, RuleFinder ruleFinder, IssueCache issueCache,
EventBus eventBus, ComponentSelector componentSelector, AnalysisMode analysisMode, UserFinder userFinder) {
this.settings = settings;
this.fileSystem = fileSystem;
this.server = server;
- this.ruleI18nManager = ruleI18nManager;
+ this.ruleFinder = ruleFinder;
this.issueCache = issueCache;
this.eventBus = eventBus;
this.componentSelector = componentSelector;
@@ -216,7 +218,8 @@ public class JsonReport implements BatchComponent {
}
private String getRuleName(RuleKey ruleKey) {
- return ruleI18nManager.getName(ruleKey.repository(), ruleKey.rule());
+ Rule rule = ruleFinder.findByKey(ruleKey);
+ return rule != null ? rule.getName() : null;
}
@VisibleForTesting
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java
index 94cabfd72eb..0b0ce6bd1a1 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JsonReportTest.java
@@ -32,13 +32,13 @@ import org.sonar.api.platform.Server;
import org.sonar.api.resources.Resource;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleFinder;
import org.sonar.api.scan.filesystem.ModuleFileSystem;
import org.sonar.api.user.User;
import org.sonar.api.user.UserFinder;
import org.sonar.batch.bootstrap.AnalysisMode;
import org.sonar.batch.events.EventBus;
import org.sonar.batch.issue.IssueCache;
-import org.sonar.core.i18n.RuleI18nManager;
import org.sonar.core.user.DefaultUser;
import org.sonar.test.TestUtils;
@@ -48,7 +48,6 @@ import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Locale;
import java.util.TimeZone;
import static org.fest.assertions.Assertions.assertThat;
@@ -67,7 +66,7 @@ public class JsonReportTest {
Resource resource = mock(Resource.class);
ModuleFileSystem fileSystem = mock(ModuleFileSystem.class);
Server server = mock(Server.class);
- RuleI18nManager ruleI18nManager = mock(RuleI18nManager.class);
+ RuleFinder ruleFinder = mock(RuleFinder.class);
Settings settings;
IssueCache issueCache = mock(IssueCache.class);
private AnalysisMode mode;
@@ -83,7 +82,7 @@ public class JsonReportTest {
mode = mock(AnalysisMode.class);
when(mode.isPreview()).thenReturn(true);
userFinder = mock(UserFinder.class);
- jsonReport = new JsonReport(settings, fileSystem, server, ruleI18nManager, issueCache, mock(EventBus.class), new DefaultComponentSelector(), mode, userFinder);
+ jsonReport = new JsonReport(settings, fileSystem, server, ruleFinder, issueCache, mock(EventBus.class), new DefaultComponentSelector(), mode, userFinder);
}
@Test
@@ -103,7 +102,7 @@ public class JsonReportTest {
.setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24"))
.setUpdateDate(SIMPLE_DATE_FORMAT.parse("2013-04-25"))
.setNew(false);
- when(ruleI18nManager.getName("squid", "AvoidCycles", Locale.getDefault())).thenReturn("Avoid Cycles");
+ when(ruleFinder.findByKey(RuleKey.of("squid", "AvoidCycles"))).thenReturn(new Rule().setName("Avoid Cycles"));
when(jsonReport.getIssues()).thenReturn(Lists.<DefaultIssue>newArrayList(issue));
DefaultUser user1 = new DefaultUser().setLogin("julien").setName("Julien");
DefaultUser user2 = new DefaultUser().setLogin("simon").setName("Simon");
@@ -118,17 +117,18 @@ public class JsonReportTest {
@Test
public void should_exclude_resolved_issues() throws Exception {
+ RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
DefaultIssue issue = new DefaultIssue()
.setKey("200")
.setComponentKey("struts:org.apache.struts.Action")
- .setRuleKey(RuleKey.of("squid", "AvoidCycles"))
+ .setRuleKey(ruleKey)
.setStatus(Issue.STATUS_CLOSED)
.setResolution(Issue.RESOLUTION_FIXED)
.setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24"))
.setUpdateDate(SIMPLE_DATE_FORMAT.parse("2013-04-25"))
.setCloseDate(SIMPLE_DATE_FORMAT.parse("2013-04-26"))
.setNew(false);
- when(ruleI18nManager.getName("squid", "AvoidCycles", Locale.getDefault())).thenReturn("Avoid Cycles");
+ when(ruleFinder.findByKey(ruleKey)).thenReturn(Rule.create(ruleKey.repository(), ruleKey.rule()).setName("Avoid Cycles"));
when(jsonReport.getIssues()).thenReturn(Lists.<DefaultIssue>newArrayList(issue));
StringWriter writer = new StringWriter();
@@ -152,8 +152,8 @@ public class JsonReportTest {
public void should_export_issues_to_file() throws IOException {
File sonarDirectory = temporaryFolder.newFolder("sonar");
- Rule rule = Rule.create("squid", "AvoidCycles");
- when(ruleI18nManager.getName(rule, Locale.getDefault())).thenReturn("Avoid Cycles");
+ Rule rule = Rule.create("squid", "AvoidCycles").setName("Avoid Cycles");
+ when(ruleFinder.findByKey(RuleKey.of("squid", "AvoidCycles"))).thenReturn(rule);
when(jsonReport.getIssues()).thenReturn(Collections.<DefaultIssue>emptyList());
settings.setProperty("sonar.report.export.path", "output.json");