3 * Copyright (C) 2009-2017 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.scanner.mediumtest.issues;
22 import com.google.common.collect.ImmutableMap;
24 import java.io.IOException;
25 import org.apache.commons.io.FileUtils;
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.rules.TemporaryFolder;
30 import org.sonar.scanner.mediumtest.ScannerMediumTester;
31 import org.sonar.scanner.mediumtest.TaskResult;
32 import org.sonar.xoo.XooPlugin;
33 import org.sonar.xoo.rule.XooRulesDefinition;
35 import static org.assertj.core.api.Assertions.assertThat;
37 public class IssuesOnModuleMediumTest {
40 public TemporaryFolder temp = new TemporaryFolder();
42 public ScannerMediumTester tester = ScannerMediumTester.builder()
43 .registerPlugin("xoo", new XooPlugin())
44 .addDefaultQProfile("xoo", "Sonar Way")
45 .addRules(new XooRulesDefinition())
46 .addActiveRule("xoo", "OneIssuePerModule", null, "One issue per module", "MINOR", "xoo", "xoo")
50 public void prepare() {
60 public void scanTempProject() throws IOException {
62 File baseDir = temp.getRoot();
63 File srcDir = new File(baseDir, "src");
66 File xooFile1 = new File(srcDir, "sample1.xoo");
67 FileUtils.write(xooFile1, "Sample1 xoo\ncontent");
69 TaskResult result = tester.newTask()
70 .properties(ImmutableMap.<String, String>builder()
71 .put("sonar.task", "scan")
72 .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
73 .put("sonar.projectKey", "com.foo.project")
74 .put("sonar.projectName", "Foo Project")
75 .put("sonar.projectVersion", "1.0-SNAPSHOT")
76 .put("sonar.projectDescription", "Description of Foo Project")
77 .put("sonar.sources", "src")
81 assertThat(result.issuesFor(result.getReportComponent("com.foo.project"))).hasSize(1);