diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-04-13 09:16:32 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-04-14 10:14:30 +0200 |
commit | 91a01dfc9e3d78cbe8b855912202540a66a74cdf (patch) | |
tree | 5865e8bba0934d31b628683605197f327f049ae4 /plugins | |
parent | bd314784e17f2b0573a9e6a25e6a7b8a231c5ed1 (diff) | |
download | sonarqube-91a01dfc9e3d78cbe8b855912202540a66a74cdf.tar.gz sonarqube-91a01dfc9e3d78cbe8b855912202540a66a74cdf.zip |
SONAR-6408 Restore PostJob execution in preview mode
Diffstat (limited to 'plugins')
5 files changed, 101 insertions, 5 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java index 8aa011ef873..a94fe8c055c 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java @@ -20,6 +20,7 @@ package org.sonar.xoo; import org.sonar.api.SonarPlugin; +import org.sonar.xoo.extensions.XooPostJob; import org.sonar.xoo.extensions.XooProjectBuilder; import org.sonar.xoo.lang.*; import org.sonar.xoo.rule.*; @@ -70,6 +71,7 @@ public class XooPlugin extends SonarPlugin { CreateIssueByInternalKeySensor.class, // Other - XooProjectBuilder.class); + XooProjectBuilder.class, + XooPostJob.class); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooPostJob.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooPostJob.java new file mode 100644 index 00000000000..80b27f29e43 --- /dev/null +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooPostJob.java @@ -0,0 +1,46 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.xoo.extensions; + +import com.google.common.collect.Iterables; +import org.sonar.api.batch.postjob.PostJob; +import org.sonar.api.batch.postjob.PostJobContext; +import org.sonar.api.batch.postjob.PostJobDescriptor; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; + +public class XooPostJob implements PostJob { + + private static final Logger LOG = Loggers.get(XooPostJob.class); + + @Override + public void describe(PostJobDescriptor descriptor) { + descriptor.name("Xoo Post Job") + .requireProperty("sonar.xoo.enablePostJob"); + + } + + @Override + public void execute(PostJobContext context) { + LOG.info("Resolved issues: " + Iterables.size(context.resolvedIssues())); + LOG.info("Open issues: " + Iterables.size(context.issues())); + } + +} diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java index 4aa4ea7e33f..fc0a564c69c 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java @@ -23,10 +23,10 @@ import org.sonar.api.batch.fs.FilePredicates; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.InputFile.Type; +import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; -import org.sonar.api.batch.sensor.issue.Issue.Severity; import org.sonar.api.rule.RuleKey; import org.sonar.xoo.Xoo; diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java new file mode 100644 index 00000000000..4af975c172e --- /dev/null +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.xoo.extensions; + +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.batch.postjob.PostJobContext; +import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; +import org.sonar.api.batch.postjob.issue.Issue; +import org.sonar.api.utils.log.LogTester; + +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class XooPostJobTest { + + @Rule + public LogTester logTester = new LogTester(); + + @Test + public void increaseCoverage() { + new XooPostJob().describe(new DefaultPostJobDescriptor()); + PostJobContext context = mock(PostJobContext.class); + when(context.issues()).thenReturn(Arrays.<Issue>asList()); + when(context.resolvedIssues()).thenReturn(Arrays.<Issue>asList()); + new XooPostJob().execute(context); + assertThat(logTester.logs()).contains("Resolved issues: 0", "Open issues: 0"); + } +} diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java index ab8ea247d35..a3cbbf5eb84 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java @@ -19,8 +19,6 @@ */ package org.sonar.xoo.rule; -import org.sonar.api.batch.sensor.internal.SensorStorage; - import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -29,10 +27,11 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.sonar.api.batch.fs.internal.DefaultFileSystem; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; +import org.sonar.api.batch.sensor.internal.SensorStorage; import org.sonar.api.batch.sensor.issue.Issue; -import org.sonar.api.batch.sensor.issue.Issue.Severity; import org.sonar.api.batch.sensor.issue.internal.DefaultIssue; import org.sonar.api.config.Settings; import org.sonar.xoo.Xoo; |