--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.scanner.deprecated.test;
+
+import java.util.List;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.CoverageBlock;
+import org.sonar.api.test.TestCase;
+import org.sonar.api.test.Testable;
+
+public class DefaultCoverageBlock implements CoverageBlock {
+
+ private final TestCase testCase;
+ private final DefaultInputFile testable;
+ private final List<Integer> lines;
+
+ public DefaultCoverageBlock(TestCase testCase, DefaultInputFile testable, List<Integer> lines) {
+ this.testCase = testCase;
+ this.testable = testable;
+ this.lines = lines;
+ }
+
+ @Override
+ public TestCase testCase() {
+ return testCase;
+ }
+
+ @Override
+ public Testable testable() {
+ return new DefaultTestable(testable);
+ }
+
+ @Override
+ public List<Integer> lines() {
+ return lines;
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.scanner.deprecated.test;
+
+import com.google.common.base.Preconditions;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.CoverageBlock;
+import org.sonar.api.test.MutableTestCase;
+import org.sonar.api.test.TestPlan;
+import org.sonar.api.test.Testable;
+import org.sonar.api.test.exception.CoverageAlreadyExistsException;
+import org.sonar.api.test.exception.IllegalDurationException;
+
+public class DefaultTestCase implements MutableTestCase {
+
+ private final DefaultTestPlan testPlan;
+ private String type;
+ private Long durationInMs;
+ private Status status;
+ private String name;
+ private String message;
+ private String stackTrace;
+ private Map<DefaultInputFile, CoverageBlock> coverageBlocksByTestedFile = new LinkedHashMap<>();
+
+ public DefaultTestCase(DefaultTestPlan testPlan) {
+ this.testPlan = testPlan;
+ }
+
+ @Override
+ public String type() {
+ return type;
+ }
+
+ @Override
+ public MutableTestCase setType(@Nullable String s) {
+ this.type = s;
+ return this;
+ }
+
+ @Override
+ public Long durationInMs() {
+ return durationInMs;
+ }
+
+ @Override
+ public MutableTestCase setDurationInMs(@Nullable Long l) {
+ if (l != null && l < 0) {
+ throw new IllegalDurationException("Test duration must be positive (got: " + l + ")");
+ }
+ this.durationInMs = l;
+ return this;
+ }
+
+ @Override
+ public Status status() {
+ return status;
+ }
+
+ @Override
+ public MutableTestCase setStatus(@Nullable Status s) {
+ this.status = s;
+ return this;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ public MutableTestCase setName(String s) {
+ this.name = s;
+ return this;
+ }
+
+ @Override
+ public String message() {
+ return message;
+ }
+
+ @Override
+ public MutableTestCase setMessage(String s) {
+ this.message = s;
+ return this;
+ }
+
+ @Override
+ public String stackTrace() {
+ return stackTrace;
+ }
+
+ @Override
+ public MutableTestCase setStackTrace(String s) {
+ this.stackTrace = s;
+ return this;
+ }
+
+ @Override
+ public MutableTestCase setCoverageBlock(Testable testable, List<Integer> lines) {
+ DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile();
+ return setCoverageBlock(coveredFile, lines);
+ }
+
+ @Override
+ public MutableTestCase setCoverageBlock(InputFile mainFile, List<Integer> lines) {
+ Preconditions.checkArgument(mainFile.type() == Type.MAIN, "Test file can only cover a main file");
+ DefaultInputFile coveredFile = (DefaultInputFile) mainFile;
+ if (coverageBlocksByTestedFile.containsKey(coveredFile)) {
+ throw new CoverageAlreadyExistsException("The link between " + name() + " and " + coveredFile.key() + " already exists");
+ }
+ coverageBlocksByTestedFile.put(coveredFile, new DefaultCoverageBlock(this, coveredFile, lines));
+ return this;
+ }
+
+ @Override
+ public TestPlan testPlan() {
+ return testPlan;
+ }
+
+ @Override
+ public boolean doesCover() {
+ return !coverageBlocksByTestedFile.isEmpty();
+ }
+
+ @Override
+ public int countCoveredLines() {
+ throw new UnsupportedOperationException("Not supported since SQ 5.2");
+ }
+
+ @Override
+ public Iterable<CoverageBlock> coverageBlocks() {
+ return coverageBlocksByTestedFile.values();
+ }
+
+ @Override
+ public CoverageBlock coverageBlock(final Testable testable) {
+ DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile();
+ return coverageBlocksByTestedFile.get(coveredFile);
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.scanner.deprecated.test;
+
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.CheckForNull;
+import org.sonar.api.test.MutableTestCase;
+import org.sonar.api.test.MutableTestPlan;
+
+public class DefaultTestPlan implements MutableTestPlan {
+ private List<MutableTestCase> testCases = new ArrayList<>();
+
+ @Override
+ @CheckForNull
+ public Iterable<MutableTestCase> testCasesByName(String name) {
+ List<MutableTestCase> result = Lists.newArrayList();
+ for (MutableTestCase testCase : testCases()) {
+ if (name.equals(testCase.name())) {
+ result.add(testCase);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public MutableTestCase addTestCase(String name) {
+ DefaultTestCase testCase = new DefaultTestCase(this);
+ testCase.setName(name);
+ testCases.add(testCase);
+ return testCase;
+ }
+
+ @Override
+ public Iterable<MutableTestCase> testCases() {
+ return testCases;
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.scanner.deprecated.test;
+
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.CoverageBlock;
+import org.sonar.api.test.MutableTestable;
+import org.sonar.api.test.TestCase;
+
+public class DefaultTestable implements MutableTestable {
+
+ private final DefaultInputFile inputFile;
+
+ public DefaultTestable(DefaultInputFile inputFile) {
+ this.inputFile = inputFile;
+ }
+
+ public DefaultInputFile inputFile() {
+ return inputFile;
+ }
+
+ @Override
+ public List<TestCase> testCases() {
+ throw unsupported();
+ }
+
+ @Override
+ public TestCase testCaseByName(final String name) {
+ throw unsupported();
+ }
+
+ @Override
+ public int countTestCasesOfLine(Integer line) {
+ throw unsupported();
+ }
+
+ @Override
+ public Map<Integer, Integer> testCasesByLines() {
+ throw unsupported();
+ }
+
+ @Override
+ public List<TestCase> testCasesOfLine(int line) {
+ throw unsupported();
+ }
+
+ @Override
+ public SortedSet<Integer> testedLines() {
+ throw unsupported();
+ }
+
+ @Override
+ public CoverageBlock coverageBlock(final TestCase testCase) {
+ throw unsupported();
+ }
+
+ @Override
+ public Iterable<CoverageBlock> coverageBlocks() {
+ throw unsupported();
+ }
+
+ private static UnsupportedOperationException unsupported() {
+ return new UnsupportedOperationException("No more available since SQ 5.2");
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.scanner.deprecated.test;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.test.MutableTestPlan;
+import org.sonar.scanner.deprecated.perspectives.PerspectiveBuilder;
+import org.sonar.scanner.index.BatchComponent;
+
+public class TestPlanBuilder extends PerspectiveBuilder<MutableTestPlan> {
+
+ private Map<InputFile, DefaultTestPlan> testPlanByFile = new HashMap<>();
+
+ public TestPlanBuilder() {
+ super(MutableTestPlan.class);
+ }
+
+ @CheckForNull
+ @Override
+ public MutableTestPlan loadPerspective(Class<MutableTestPlan> perspectiveClass, BatchComponent component) {
+ if (component.isFile()) {
+ InputFile inputFile = (InputFile) component.inputComponent();
+ if (inputFile.type() == Type.TEST) {
+ if (!testPlanByFile.containsKey(inputFile)) {
+ testPlanByFile.put(inputFile, new DefaultTestPlan());
+ }
+ return testPlanByFile.get(inputFile);
+ }
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.scanner.deprecated.test;
+
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.MutableTestable;
+import org.sonar.scanner.deprecated.perspectives.PerspectiveBuilder;
+import org.sonar.scanner.index.BatchComponent;
+
+public class TestableBuilder extends PerspectiveBuilder<MutableTestable> {
+
+ public TestableBuilder() {
+ super(MutableTestable.class);
+ }
+
+ @CheckForNull
+ @Override
+ public MutableTestable loadPerspective(Class<MutableTestable> perspectiveClass, BatchComponent component) {
+ if (component.isFile()) {
+ InputFile inputFile = (InputFile) component.inputComponent();
+ if (inputFile.type() == Type.MAIN) {
+ return new DefaultTestable((DefaultInputFile) inputFile);
+ }
+ }
+ return null;
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.scanner.deprecated.test;
+
+import javax.annotation.ParametersAreNonnullByDefault;
import org.sonar.api.test.MutableTestCase;
import org.sonar.api.test.MutableTestPlan;
import org.sonar.api.test.TestCase;
+import org.sonar.scanner.deprecated.test.DefaultTestable;
+import org.sonar.scanner.deprecated.test.TestPlanBuilder;
import org.sonar.scanner.index.BatchComponent;
import org.sonar.scanner.index.BatchComponentCache;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReport.CoverageDetail;
import org.sonar.scanner.protocol.output.ScannerReport.Test;
import org.sonar.scanner.protocol.output.ScannerReport.Test.TestStatus;
-import org.sonar.scanner.test.DefaultTestable;
-import org.sonar.scanner.test.TestPlanBuilder;
import org.sonar.scanner.protocol.output.ScannerReportWriter;
public class TestExecutionAndCoveragePublisher implements ReportPublisherStep {
import org.sonar.scanner.bootstrap.MetricProvider;
import org.sonar.scanner.cpd.CpdExecutor;
import org.sonar.scanner.cpd.index.SonarCpdBlockIndex;
+import org.sonar.scanner.deprecated.test.TestPlanBuilder;
+import org.sonar.scanner.deprecated.test.TestableBuilder;
import org.sonar.scanner.events.EventBus;
import org.sonar.scanner.index.BatchComponentCache;
import org.sonar.scanner.index.DefaultIndex;
import org.sonar.scanner.scan.measure.MeasureCache;
import org.sonar.scanner.source.CodeColorizers;
import org.sonar.scanner.storage.Storages;
-import org.sonar.scanner.test.TestPlanBuilder;
-import org.sonar.scanner.test.TestableBuilder;
public class ProjectScanContainer extends ComponentContainer {
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.scanner.test;
-
-import java.util.List;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.test.CoverageBlock;
-import org.sonar.api.test.TestCase;
-import org.sonar.api.test.Testable;
-
-public class DefaultCoverageBlock implements CoverageBlock {
-
- private final TestCase testCase;
- private final DefaultInputFile testable;
- private final List<Integer> lines;
-
- public DefaultCoverageBlock(TestCase testCase, DefaultInputFile testable, List<Integer> lines) {
- this.testCase = testCase;
- this.testable = testable;
- this.lines = lines;
- }
-
- @Override
- public TestCase testCase() {
- return testCase;
- }
-
- @Override
- public Testable testable() {
- return new DefaultTestable(testable);
- }
-
- @Override
- public List<Integer> lines() {
- return lines;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.scanner.test;
-
-import com.google.common.base.Preconditions;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.Nullable;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.InputFile.Type;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.test.CoverageBlock;
-import org.sonar.api.test.MutableTestCase;
-import org.sonar.api.test.TestPlan;
-import org.sonar.api.test.Testable;
-import org.sonar.api.test.exception.CoverageAlreadyExistsException;
-import org.sonar.api.test.exception.IllegalDurationException;
-
-public class DefaultTestCase implements MutableTestCase {
-
- private final DefaultTestPlan testPlan;
- private String type;
- private Long durationInMs;
- private Status status;
- private String name;
- private String message;
- private String stackTrace;
- private Map<DefaultInputFile, CoverageBlock> coverageBlocksByTestedFile = new LinkedHashMap<>();
-
- public DefaultTestCase(DefaultTestPlan testPlan) {
- this.testPlan = testPlan;
- }
-
- @Override
- public String type() {
- return type;
- }
-
- @Override
- public MutableTestCase setType(@Nullable String s) {
- this.type = s;
- return this;
- }
-
- @Override
- public Long durationInMs() {
- return durationInMs;
- }
-
- @Override
- public MutableTestCase setDurationInMs(@Nullable Long l) {
- if (l != null && l < 0) {
- throw new IllegalDurationException("Test duration must be positive (got: " + l + ")");
- }
- this.durationInMs = l;
- return this;
- }
-
- @Override
- public Status status() {
- return status;
- }
-
- @Override
- public MutableTestCase setStatus(@Nullable Status s) {
- this.status = s;
- return this;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- public MutableTestCase setName(String s) {
- this.name = s;
- return this;
- }
-
- @Override
- public String message() {
- return message;
- }
-
- @Override
- public MutableTestCase setMessage(String s) {
- this.message = s;
- return this;
- }
-
- @Override
- public String stackTrace() {
- return stackTrace;
- }
-
- @Override
- public MutableTestCase setStackTrace(String s) {
- this.stackTrace = s;
- return this;
- }
-
- @Override
- public MutableTestCase setCoverageBlock(Testable testable, List<Integer> lines) {
- DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile();
- return setCoverageBlock(coveredFile, lines);
- }
-
- @Override
- public MutableTestCase setCoverageBlock(InputFile mainFile, List<Integer> lines) {
- Preconditions.checkArgument(mainFile.type() == Type.MAIN, "Test file can only cover a main file");
- DefaultInputFile coveredFile = (DefaultInputFile) mainFile;
- if (coverageBlocksByTestedFile.containsKey(coveredFile)) {
- throw new CoverageAlreadyExistsException("The link between " + name() + " and " + coveredFile.key() + " already exists");
- }
- coverageBlocksByTestedFile.put(coveredFile, new DefaultCoverageBlock(this, coveredFile, lines));
- return this;
- }
-
- @Override
- public TestPlan testPlan() {
- return testPlan;
- }
-
- @Override
- public boolean doesCover() {
- return !coverageBlocksByTestedFile.isEmpty();
- }
-
- @Override
- public int countCoveredLines() {
- throw new UnsupportedOperationException("Not supported since SQ 5.2");
- }
-
- @Override
- public Iterable<CoverageBlock> coverageBlocks() {
- return coverageBlocksByTestedFile.values();
- }
-
- @Override
- public CoverageBlock coverageBlock(final Testable testable) {
- DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile();
- return coverageBlocksByTestedFile.get(coveredFile);
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.scanner.test;
-
-import com.google.common.collect.Lists;
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import org.sonar.api.test.MutableTestCase;
-import org.sonar.api.test.MutableTestPlan;
-
-public class DefaultTestPlan implements MutableTestPlan {
- private List<MutableTestCase> testCases = new ArrayList<>();
-
- @Override
- @CheckForNull
- public Iterable<MutableTestCase> testCasesByName(String name) {
- List<MutableTestCase> result = Lists.newArrayList();
- for (MutableTestCase testCase : testCases()) {
- if (name.equals(testCase.name())) {
- result.add(testCase);
- }
- }
- return result;
- }
-
- @Override
- public MutableTestCase addTestCase(String name) {
- DefaultTestCase testCase = new DefaultTestCase(this);
- testCase.setName(name);
- testCases.add(testCase);
- return testCase;
- }
-
- @Override
- public Iterable<MutableTestCase> testCases() {
- return testCases;
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.scanner.test;
-
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.test.CoverageBlock;
-import org.sonar.api.test.MutableTestable;
-import org.sonar.api.test.TestCase;
-
-public class DefaultTestable implements MutableTestable {
-
- private final DefaultInputFile inputFile;
-
- public DefaultTestable(DefaultInputFile inputFile) {
- this.inputFile = inputFile;
- }
-
- public DefaultInputFile inputFile() {
- return inputFile;
- }
-
- @Override
- public List<TestCase> testCases() {
- throw unsupported();
- }
-
- @Override
- public TestCase testCaseByName(final String name) {
- throw unsupported();
- }
-
- @Override
- public int countTestCasesOfLine(Integer line) {
- throw unsupported();
- }
-
- @Override
- public Map<Integer, Integer> testCasesByLines() {
- throw unsupported();
- }
-
- @Override
- public List<TestCase> testCasesOfLine(int line) {
- throw unsupported();
- }
-
- @Override
- public SortedSet<Integer> testedLines() {
- throw unsupported();
- }
-
- @Override
- public CoverageBlock coverageBlock(final TestCase testCase) {
- throw unsupported();
- }
-
- @Override
- public Iterable<CoverageBlock> coverageBlocks() {
- throw unsupported();
- }
-
- private static UnsupportedOperationException unsupported() {
- return new UnsupportedOperationException("No more available since SQ 5.2");
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.scanner.test;
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.annotation.CheckForNull;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.InputFile.Type;
-import org.sonar.api.test.MutableTestPlan;
-import org.sonar.scanner.deprecated.perspectives.PerspectiveBuilder;
-import org.sonar.scanner.index.BatchComponent;
-
-public class TestPlanBuilder extends PerspectiveBuilder<MutableTestPlan> {
-
- private Map<InputFile, DefaultTestPlan> testPlanByFile = new HashMap<>();
-
- public TestPlanBuilder() {
- super(MutableTestPlan.class);
- }
-
- @CheckForNull
- @Override
- public MutableTestPlan loadPerspective(Class<MutableTestPlan> perspectiveClass, BatchComponent component) {
- if (component.isFile()) {
- InputFile inputFile = (InputFile) component.inputComponent();
- if (inputFile.type() == Type.TEST) {
- if (!testPlanByFile.containsKey(inputFile)) {
- testPlanByFile.put(inputFile, new DefaultTestPlan());
- }
- return testPlanByFile.get(inputFile);
- }
- }
- return null;
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.scanner.test;
-
-import javax.annotation.CheckForNull;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.InputFile.Type;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.test.MutableTestable;
-import org.sonar.scanner.deprecated.perspectives.PerspectiveBuilder;
-import org.sonar.scanner.index.BatchComponent;
-
-public class TestableBuilder extends PerspectiveBuilder<MutableTestable> {
-
- public TestableBuilder() {
- super(MutableTestable.class);
- }
-
- @CheckForNull
- @Override
- public MutableTestable loadPerspective(Class<MutableTestable> perspectiveClass, BatchComponent component) {
- if (component.isFile()) {
- InputFile inputFile = (InputFile) component.inputComponent();
- if (inputFile.type() == Type.MAIN) {
- return new DefaultTestable((DefaultInputFile) inputFile);
- }
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.scanner.test;
-
-import javax.annotation.ParametersAreNonnullByDefault;