diff options
| author | Elena Vilchik | 2020-01-03 09:18:10 +0100 |
|---|---|---|
| committer | Christophe Zürn | 2020-01-03 09:18:10 +0100 |
| commit | 6258d923a5f42e00ddaf0ed45271933b2294b2fc (patch) | |
| tree | 6a1c07fc2940ed611072e36f500d01cb35a2b2d3 /its/plugin/src/test/java | |
| parent | 7bb9065e87f97dc41d6d22e8d3cb7741f6d08998 (diff) | |
| download | sonar-css-6258d923a5f42e00ddaf0ed45271933b2294b2fc.tar.bz2 | |
Rely on run-node on Mac (#236)
Diffstat (limited to 'its/plugin/src/test/java')
| -rw-r--r-- | its/plugin/src/test/java/org/sonar/css/its/NonStandardPathTest.java | 75 | ||||
| -rw-r--r-- | its/plugin/src/test/java/org/sonar/css/its/Tests.java | 6 |
2 files changed, 80 insertions, 1 deletions
diff --git a/its/plugin/src/test/java/org/sonar/css/its/NonStandardPathTest.java b/its/plugin/src/test/java/org/sonar/css/its/NonStandardPathTest.java new file mode 100644 index 0000000..5fc1793 --- /dev/null +++ b/its/plugin/src/test/java/org/sonar/css/its/NonStandardPathTest.java @@ -0,0 +1,75 @@ +/* + * SonarCSS + * Copyright (C) 2018-2019 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 com.sonar.orchestrator.build.SonarScanner; +import com.sonar.orchestrator.locator.FileLocation; +import java.io.File; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +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 org.sonarsource.analyzer.commons.ProfileGenerator; +import org.sonarsource.analyzer.commons.ProfileGenerator.RulesConfiguration; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; +import static org.sonar.css.its.Tests.newWsClient; + +public class NonStandardPathTest { + + private static String PROJECT_KEY = "dir-with-paren"; + + @ClassRule + public static Orchestrator orchestrator = Tests.ORCHESTRATOR; + + @BeforeClass + public static void prepare() { + RulesConfiguration rulesConfiguration = new RulesConfiguration(); + File profile = ProfileGenerator.generateProfile(orchestrator.getServer().getUrl(), "css", "css", rulesConfiguration, Collections.emptySet()); + orchestrator.getServer().restoreProfile(FileLocation.of(profile)); + + orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY); + orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "css", "rules"); + + File projectDir = FileLocation.of("projects" + File.separator + "(dir with paren)").getFile(); + SonarScanner scanner = Tests.createScanner(PROJECT_KEY, projectDir); + orchestrator.executeBuild(scanner); + } + + @Test + public void test() { + SearchRequest request = new SearchRequest(); + request.setComponentKeys(Collections.singletonList(PROJECT_KEY)); + List<Issue> issuesList = newWsClient().issues().search(request).getIssuesList().stream() + .filter(i -> i.getRule().startsWith("css:")) + .collect(Collectors.toList()); + + assertThat(issuesList).extracting(Issue::getRule, Issue::getComponent).containsExactly( + tuple("css:S1128", "dir-with-paren:src/file1.css") + ); + } + +} 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 d3e62c7..eeb35a0 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 @@ -43,7 +43,8 @@ import org.sonarqube.ws.client.measures.ComponentRequest; IssuesTest.class, NoCssFileProjectTest.class, StylelintReportTest.class, - MinifiedTest.class + MinifiedTest.class, + NonStandardPathTest.class }) public class Tests { @@ -86,7 +87,10 @@ public class Tests { public static SonarScanner createScanner(String projectKey) { File projectDir = FileLocation.of("projects" + File.separator + projectKey).getFile(); + return createScanner(projectKey, projectDir); + } + public static SonarScanner createScanner(String projectKey, File projectDir) { return SonarScanner.create() .setSourceEncoding("UTF-8") .setProjectDir(projectDir) |
