aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-xoo-plugin/src/test/java/org/sonar
diff options
context:
space:
mode:
authorMathieu Suen <mathieu.suen@sonarsource.com>2021-10-11 14:58:08 +0200
committersonartech <sonartech@sonarsource.com>2021-10-13 20:03:34 +0000
commitb565cf9454043c9c1c05880327491a9122368e02 (patch)
tree5dfbde868d4d297783a4bbda8142841f36be32a4 /plugins/sonar-xoo-plugin/src/test/java/org/sonar
parentb5fbdff6d4c84c5fbc26adc5a07170fc7ba5acf4 (diff)
downloadsonarqube-b565cf9454043c9c1c05880327491a9122368e02.tar.gz
sonarqube-b565cf9454043c9c1c05880327491a9122368e02.zip
SONAR-15473 Add IT on quick fix available for issue
Diffstat (limited to 'plugins/sonar-xoo-plugin/src/test/java/org/sonar')
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneQuickFixPerLineSensorTest.java73
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java4
2 files changed, 75 insertions, 2 deletions
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneQuickFixPerLineSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneQuickFixPerLineSensorTest.java
new file mode 100644
index 00000000000..de9e0b08e7c
--- /dev/null
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneQuickFixPerLineSensorTest.java
@@ -0,0 +1,73 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.rule;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.api.SonarEdition;
+import org.sonar.api.SonarQubeSide;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.rule.Severity;
+import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
+import org.sonar.api.batch.sensor.internal.SensorContextTester;
+import org.sonar.api.batch.sensor.issue.Issue;
+import org.sonar.api.config.internal.MapSettings;
+import org.sonar.api.internal.SonarRuntimeImpl;
+import org.sonar.api.utils.Version;
+import org.sonar.xoo.Xoo;
+
+import java.io.IOException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class OneQuickFixPerLineSensorTest {
+
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
+ private OneQuickFixPerLineSensor sensor = new OneQuickFixPerLineSensor();
+
+ @Test
+ public void testDescriptor() {
+ DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
+ sensor.describe(descriptor);
+ assertThat(descriptor.ruleRepositories()).containsOnly(XooRulesDefinition.XOO_REPOSITORY, XooRulesDefinition.XOO2_REPOSITORY);
+ }
+
+ @Test
+ public void testRule() throws IOException {
+ DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.xoo")
+ .setLanguage(Xoo.KEY)
+ .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n")
+ .build();
+
+ SensorContextTester context = SensorContextTester.create(temp.newFolder());
+ context.fileSystem().add(inputFile);
+ sensor.execute(context);
+
+ assertThat(context.allIssues()).hasSize(10); // One issue per line
+ for (Issue issue : context.allIssues()) {
+ assertThat(issue.isQuickFixAvailable()).isTrue();
+ }
+ }
+
+}
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
index 8741205285b..2160c1bc0e5 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
@@ -48,7 +48,7 @@ public class XooRulesDefinitionTest {
assertThat(repo).isNotNull();
assertThat(repo.name()).isEqualTo("Xoo");
assertThat(repo.language()).isEqualTo("xoo");
- assertThat(repo.rules()).hasSize(22);
+ assertThat(repo.rules()).hasSize(23);
RulesDefinition.Rule rule = repo.rule(OneIssuePerLineSensor.RULE_KEY);
assertThat(rule.name()).isNotEmpty();
@@ -64,7 +64,7 @@ public class XooRulesDefinitionTest {
assertThat(repo).isNotNull();
assertThat(repo.name()).isEqualTo("Xoo");
assertThat(repo.language()).isEqualTo("xoo");
- assertThat(repo.rules()).hasSize(22);
+ assertThat(repo.rules()).hasSize(23);
RulesDefinition.Rule rule = repo.rule(HotspotSensor.RULE_KEY);
assertThat(rule.name()).isNotEmpty();