aboutsummaryrefslogtreecommitdiffstats
path: root/its/plugin/src/test/java
diff options
context:
space:
mode:
authorElena Vilchik2018-06-22 18:03:05 +0200
committerAmaury Levé2018-06-22 18:03:05 +0200
commit88cc2bbfbda30d8ba8148dd4a7d0392a3171fe50 (patch)
tree9fbe1cd5e45c63c1958e63fd0189d761b2afd563 /its/plugin/src/test/java
parent7385260825c79419a920bdf835e925cef916b404 (diff)
downloadsonar-css-88cc2bbfbda30d8ba8148dd4a7d0392a3171fe50.tar.bz2
Support import of external stylelint issues report (#65)
Diffstat (limited to 'its/plugin/src/test/java')
-rw-r--r--its/plugin/src/test/java/org/sonar/css/its/StylelintReportTest.java62
-rw-r--r--its/plugin/src/test/java/org/sonar/css/its/Tests.java4
2 files changed, 65 insertions, 1 deletions
diff --git a/its/plugin/src/test/java/org/sonar/css/its/StylelintReportTest.java b/its/plugin/src/test/java/org/sonar/css/its/StylelintReportTest.java
new file mode 100644
index 0000000..b10f7a4
--- /dev/null
+++ b/its/plugin/src/test/java/org/sonar/css/its/StylelintReportTest.java
@@ -0,0 +1,62 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 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.css.its;
+
+import com.sonar.orchestrator.Orchestrator;
+import java.util.Collections;
+import java.util.List;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.Issues.Issue;
+import org.sonarqube.ws.client.issues.SearchRequest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.css.its.Tests.newWsClient;
+
+public class StylelintReportTest {
+
+ private static String PROJECT_KEY = "external-report-project";
+
+ @ClassRule
+ public static Orchestrator orchestrator = Tests.ORCHESTRATOR;
+
+ @BeforeClass
+ public static void prepare() {
+ orchestrator.executeBuild(Tests.createScanner(PROJECT_KEY).setProperty("sonar.css.stylelint.reportPaths", "report.json"));
+ }
+
+ @Test
+ public void test() {
+ if (orchestrator.getServer().version().isGreaterThanOrEquals(7, 2)) {
+ SearchRequest request = new SearchRequest();
+ request.setComponentKeys(Collections.singletonList(PROJECT_KEY));
+ List<Issue> issuesList = newWsClient().issues().search(request).getIssuesList();
+
+ assertThat(issuesList).extracting("line").containsExactlyInAnyOrder(111, 81, 55, 58, 114);
+ assertThat(issuesList).extracting("rule").containsExactlyInAnyOrder(
+ "external_stylelint:no-missing-end-of-source-newline",
+ "external_stylelint:no-missing-end-of-source-newline",
+ "external_stylelint:rule-empty-line-before",
+ "external_stylelint:selector-pseudo-element-colon-notation",
+ "external_stylelint:block-no-empty");
+ }
+ }
+}
diff --git a/its/plugin/src/test/java/org/sonar/css/its/Tests.java b/its/plugin/src/test/java/org/sonar/css/its/Tests.java
index 31b2f78..d94a633 100644
--- a/its/plugin/src/test/java/org/sonar/css/its/Tests.java
+++ b/its/plugin/src/test/java/org/sonar/css/its/Tests.java
@@ -29,6 +29,7 @@ import java.util.List;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
+import org.sonar.css.plugin.StylelintReport;
import org.sonarqube.ws.Measures.ComponentWsResponse;
import org.sonarqube.ws.Measures.Measure;
import org.sonarqube.ws.client.HttpConnector;
@@ -39,7 +40,8 @@ import org.sonarqube.ws.client.measures.ComponentRequest;
@RunWith(Suite.class)
@Suite.SuiteClasses({
MetricsTest.class,
- IssuesTest.class
+ IssuesTest.class,
+ StylelintReportTest.class
})
public class Tests {