]> source.dussan.org Git - sonarqube.git/commitdiff
Move old test API to deprecated package
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 19 Oct 2016 08:33:11 +0000 (10:33 +0200)
committerJulien HENRY <henryju@yahoo.fr>
Fri, 21 Oct 2016 11:17:30 +0000 (13:17 +0200)
16 files changed:
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultCoverageBlock.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestPlan.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestable.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestPlanBuilder.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestableBuilder.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/package-info.java [new file with mode: 0644]
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionAndCoveragePublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultCoverageBlock.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestCase.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestPlan.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestable.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/test/TestPlanBuilder.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/test/TestableBuilder.java [deleted file]
sonar-scanner-engine/src/main/java/org/sonar/scanner/test/package-info.java [deleted file]

diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultCoverageBlock.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultCoverageBlock.java
new file mode 100644 (file)
index 0000000..95d8e2a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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;
+  }
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestCase.java
new file mode 100644 (file)
index 0000000..522b473
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * 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);
+  }
+
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestPlan.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestPlan.java
new file mode 100644 (file)
index 0000000..0c64de4
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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;
+  }
+
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestable.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/DefaultTestable.java
new file mode 100644 (file)
index 0000000..e590672
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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");
+  }
+
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestPlanBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestPlanBuilder.java
new file mode 100644 (file)
index 0000000..94fbfd0
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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;
+  }
+
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestableBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/TestableBuilder.java
new file mode 100644 (file)
index 0000000..4c9c3de
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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;
+  }
+}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/package-info.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/test/package-info.java
new file mode 100644 (file)
index 0000000..d0d8c9b
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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;
index c920a34f0fea72fe81fa35170314b11ef5fd240b..e5f7cc0cbe192dcd720b7b39907f710d42c6fb09 100644 (file)
@@ -30,14 +30,14 @@ import org.sonar.api.test.CoverageBlock;
 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 {
index 310acabe7413e4ecc4fdb0a24bd6f042677073db..c7c34eb64d24c984bac2e1ed7b0659238b2fc502 100644 (file)
@@ -42,6 +42,8 @@ import org.sonar.scanner.bootstrap.ExtensionUtils;
 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;
@@ -90,8 +92,6 @@ import org.sonar.scanner.scan.measure.DeprecatedMetricFinder;
 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 {
 
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultCoverageBlock.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultCoverageBlock.java
deleted file mode 100644 (file)
index 003a099..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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;
-  }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestCase.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestCase.java
deleted file mode 100644 (file)
index b87cee9..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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);
-  }
-
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestPlan.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestPlan.java
deleted file mode 100644 (file)
index 65f7da1..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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;
-  }
-
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestable.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/DefaultTestable.java
deleted file mode 100644 (file)
index cf99ba2..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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");
-  }
-
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/TestPlanBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/TestPlanBuilder.java
deleted file mode 100644 (file)
index 7376eb0..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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;
-  }
-
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/TestableBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/TestableBuilder.java
deleted file mode 100644 (file)
index 2f327a3..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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;
-  }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/package-info.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/test/package-info.java
deleted file mode 100644 (file)
index e52c370..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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;