aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-02-19 16:49:10 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-02-19 22:28:59 +0100
commit0f517d524485bcc0acb47a7f00d54b2e1bac4f50 (patch)
treeff618f5e8d4886dae0f2e16254f76b67dd2203fc /sonar-plugin-api
parenteac465bea9f5bf89a7beb8036e4d8eea4723f421 (diff)
downloadsonarqube-0f517d524485bcc0acb47a7f00d54b2e1bac4f50.tar.gz
sonarqube-0f517d524485bcc0acb47a7f00d54b2e1bac4f50.zip
SONAR-5931 Remove beta test API
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java21
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/Coverage.java103
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseCoverage.java77
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseExecution.java125
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverage.java153
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverage.java138
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecution.java181
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/package-info.java22
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/package-info.java22
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverageTest.java274
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverageTest.java83
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecutionTest.java123
13 files changed, 1 insertions, 1327 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java
index a1de94d8b3f..336a7eef61a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java
@@ -31,9 +31,6 @@ import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.batch.sensor.measure.NewMeasure;
import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
-import org.sonar.api.batch.sensor.test.Coverage;
-import org.sonar.api.batch.sensor.test.TestCaseCoverage;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
import org.sonar.api.config.Settings;
import java.io.Serializable;
@@ -102,23 +99,7 @@ public interface SensorContext {
// ------------ TESTS ------------
- /**
- * Create a new coverage report.
- * Don't forget to call {@link Coverage#save()} once all parameters are provided.
- */
- Coverage newCoverage();
-
- /**
- * Create a new test case execution report.
- * Don't forget to call {@link TestCaseExecution#save()} once all parameters are provided.
- */
- TestCaseExecution newTestCaseExecution();
-
- /**
- * Create a new test case coverage report.
- * Don't forget to call {@link TestCaseCoverage#save()} once all parameters are provided.
- */
- TestCaseCoverage newTestCaseCoverage();
+ // TODO
// ------------ DEPENDENCIES ------------
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java
index 1c1218ea424..7ee6b308936 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorStorage.java
@@ -23,8 +23,6 @@ import org.sonar.api.batch.sensor.dependency.Dependency;
import org.sonar.api.batch.sensor.duplication.Duplication;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.measure.Measure;
-import org.sonar.api.batch.sensor.test.TestCaseCoverage;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
/**
* Interface for storing data computed by sensors.
@@ -38,10 +36,6 @@ public interface SensorStorage {
void store(Duplication duplication);
- void store(TestCaseExecution testCaseExecution);
-
void store(Dependency dependency);
- void store(TestCaseCoverage testCaseCoverage);
-
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/Coverage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/Coverage.java
deleted file mode 100644
index 91817547ccd..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/Coverage.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test;
-
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measure.Metric;
-import org.sonar.api.measures.CoreMetrics;
-
-/**
- * @since 5.0
- */
-public interface Coverage {
-
- public enum CoverageType {
- UNIT(CoreMetrics.LINES_TO_COVER, CoreMetrics.UNCOVERED_LINES, CoreMetrics.COVERAGE_LINE_HITS_DATA, CoreMetrics.CONDITIONS_TO_COVER, CoreMetrics.UNCOVERED_CONDITIONS,
- CoreMetrics.CONDITIONS_BY_LINE, CoreMetrics.COVERED_CONDITIONS_BY_LINE),
- INTEGRATION(CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, CoreMetrics.IT_CONDITIONS_TO_COVER,
- CoreMetrics.IT_UNCOVERED_CONDITIONS, CoreMetrics.IT_CONDITIONS_BY_LINE, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE),
- OVERALL(CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA, CoreMetrics.OVERALL_CONDITIONS_TO_COVER,
- CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.OVERALL_CONDITIONS_BY_LINE, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE);
-
- private Metric<Integer> linesToCover;
- private Metric<Integer> uncoveredLines;
- private Metric<String> lineHitsData;
- private Metric<Integer> conditionsToCover;
- private Metric<Integer> uncoveredConditions;
- private Metric<String> conditionsByLine;
- private Metric<String> coveredConditionsByLine;
-
- private CoverageType(Metric<Integer> linesToCover, Metric<Integer> uncoveredLines, Metric<String> lineHitsData, Metric<Integer> conditionsToCover,
- Metric<Integer> uncoveredConditions, Metric<String> conditionsByLine, Metric<String> coveredConditionsByLine) {
- this.linesToCover = linesToCover;
- this.uncoveredLines = uncoveredLines;
- this.lineHitsData = lineHitsData;
- this.conditionsToCover = conditionsToCover;
- this.uncoveredConditions = uncoveredConditions;
- this.conditionsByLine = conditionsByLine;
- this.coveredConditionsByLine = coveredConditionsByLine;
- }
-
- public Metric<Integer> linesToCover() {
- return linesToCover;
- }
-
- public Metric<Integer> uncoveredLines() {
- return uncoveredLines;
- }
-
- public Metric<String> lineHitsData() {
- return lineHitsData;
- }
-
- public Metric<Integer> conditionsToCover() {
- return conditionsToCover;
- }
-
- public Metric<Integer> uncoveredConditions() {
- return uncoveredConditions;
- }
-
- public Metric<String> conditionsByLine() {
- return conditionsByLine;
- }
-
- public Metric<String> coveredConditionsByLine() {
- return coveredConditionsByLine;
- }
- }
-
- /**
- * The file you are storing coverage on.
- */
- Coverage onFile(InputFile inputFile);
-
- Coverage ofType(CoverageType type);
-
- Coverage lineHits(int line, int hits);
-
- Coverage conditions(int line, int conditions, int coveredConditions);
-
- /**
- * Call this method only once when your are done with defining the test case coverage.
- */
- void save();
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseCoverage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseCoverage.java
deleted file mode 100644
index 4d620428d11..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseCoverage.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test;
-
-import org.sonar.api.batch.fs.InputFile;
-
-import java.util.List;
-
-/**
- * Represents line coverage produced by a single test in a test file on a single main file.
- * @since 5.0
- */
-public interface TestCaseCoverage {
-
- /**
- * InputFile where this test is located.
- */
- InputFile testFile();
-
- /**
- * Set file where this test is located. Mandatory.
- */
- TestCaseCoverage testFile(InputFile testFile);
-
- /**
- * Name of this test case.
- */
- String testName();
-
- /**
- * Set name of this test. Name is mandatory.
- */
- TestCaseCoverage testName(String name);
-
- /**
- * InputFile covered by this test.
- */
- InputFile coveredFile();
-
- /**
- * Set file covered by this test. Mandatory.
- */
- TestCaseCoverage cover(InputFile mainFile);
-
- /**
- * List of line numbers (1-based) covered by this test.
- */
- List<Integer> coveredLines();
-
- /**
- * Set list of line numbers (1-based) covered by this test. Mandatory.
- */
- TestCaseCoverage onLines(List<Integer> lines);
-
- /**
- * Call this method only once when your are done with defining the test case coverage.
- */
- void save();
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseExecution.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseExecution.java
deleted file mode 100644
index 9a9bf4bb072..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/TestCaseExecution.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test;
-
-import org.sonar.api.batch.fs.InputFile;
-
-import javax.annotation.Nullable;
-
-/**
- * Represents result of execution of a single test in a test file.
- * @since 5.0
- */
-public interface TestCaseExecution {
-
- /**
- * Test execution status.
- */
- enum Status {
- OK, FAILURE, ERROR, SKIPPED;
-
- public static Status of(@Nullable String s) {
- return s == null ? null : valueOf(s.toUpperCase());
- }
- }
-
- /**
- * Test type.
- */
- enum Type {
- UNIT, INTEGRATION;
- }
-
- /**
- * InputFile where this test is located.
- */
- InputFile testFile();
-
- /**
- * Set file where this test is located. Mandatory.
- */
- TestCaseExecution inTestFile(InputFile testFile);
-
- /**
- * Duration in milliseconds
- */
- Long durationInMs();
-
- /**
- * Duration in milliseconds
- */
- TestCaseExecution durationInMs(long duration);
-
- /**
- * Name of this test case.
- */
- String name();
-
- /**
- * Set name of this test. Name is mandatory.
- */
- TestCaseExecution name(String name);
-
- /**
- * Status of execution of the test.
- */
- Status status();
-
- /**
- * Status of execution of the test.
- */
- TestCaseExecution status(Status status);
-
- /**
- * Message (usually in case of {@link Status#ERROR} or {@link Status#FAILURE}).
- */
- String message();
-
- /**
- * Message (usually in case of {@link Status#ERROR} or {@link Status#FAILURE}).
- */
- TestCaseExecution message(String message);
-
- /**
- * Type of test.
- */
- Type type();
-
- /**
- * Type of test.
- */
- TestCaseExecution ofType(Type type);
-
- /**
- * Stacktrace (usually in case of {@link Status#ERROR}).
- */
- String stackTrace();
-
- /**
- * Set stacktrace (usually in case of {@link Status#ERROR}).
- */
- TestCaseExecution stackTrace(String stackTrace);
-
- /**
- * Call this method only once when your are done with defining the test case execution.
- */
- void save();
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverage.java
deleted file mode 100644
index 451ec6d912e..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverage.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test.internal;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.InputFile.Type;
-import org.sonar.api.batch.sensor.SensorStorage;
-import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
-import org.sonar.api.batch.sensor.test.Coverage;
-import org.sonar.api.utils.KeyValueFormat;
-
-import java.util.SortedMap;
-
-public final class DefaultCoverage implements Coverage {
-
- private static final String INPUT_FILE_SHOULD_BE_NON_NULL = "InputFile should be non null";
-
- private InputFile file;
- private CoverageType type;
- private int totalCoveredLines = 0, totalConditions = 0, totalCoveredConditions = 0;
- private SortedMap<Integer, Integer> hitsByLine = Maps.newTreeMap();
- private SortedMap<Integer, Integer> conditionsByLine = Maps.newTreeMap();
- private SortedMap<Integer, Integer> coveredConditionsByLine = Maps.newTreeMap();
-
- protected final transient SensorStorage storage;
- private transient boolean saved = false;
-
- public DefaultCoverage() {
- this.storage = null;
- }
-
- public DefaultCoverage(SensorStorage storage) {
- this.storage = storage;
- }
-
- @Override
- public DefaultCoverage lineHits(int lineId, int hits) {
- Preconditions.checkArgument(lineId >= 1, "Line number should be positive and non zero [" + file.relativePath() + ":" + lineId + "]");
- Preconditions.checkArgument(hits >= 0, "Hits should be positive [" + file.relativePath() + ":" + lineId + "]");
- Preconditions.checkArgument(!hitsByLine.containsKey(lineId), "Hits already saved on line [" + file.relativePath() + ":" + lineId + "]");
- hitsByLine.put(lineId, hits);
- if (hits > 0) {
- totalCoveredLines += 1;
- }
- return this;
- }
-
- @Override
- public DefaultCoverage conditions(int lineId, int conditions, int coveredConditions) {
- Preconditions.checkArgument(lineId >= 1, "Line number should be positive and non zero [" + file.relativePath() + ":" + lineId + "]");
- Preconditions.checkArgument(conditions >= 0, "Number of conditions should be positive [" + file.relativePath() + ":" + lineId + "]");
- Preconditions.checkArgument(coveredConditions >= 0, "Number of covered conditions should be positive [" + file.relativePath() + ":" + lineId + "]");
- Preconditions.checkArgument(conditions >= coveredConditions, "Number of covered conditions can't exceed conditions [" + file.relativePath() + ":" + lineId + "]");
- Preconditions.checkArgument(!conditionsByLine.containsKey(lineId), "Conditions already saved on line [" + file.relativePath() + ":" + lineId + "]");
- totalConditions += conditions;
- totalCoveredConditions += coveredConditions;
- conditionsByLine.put(lineId, conditions);
- coveredConditionsByLine.put(lineId, coveredConditions);
- return this;
- }
-
- public InputFile file() {
- return file;
- }
-
- @Override
- public DefaultCoverage onFile(InputFile inputFile) {
- Preconditions.checkNotNull(inputFile, INPUT_FILE_SHOULD_BE_NON_NULL);
- Preconditions.checkArgument(inputFile.type() == Type.MAIN, "Coverage is only supported on main files [" + inputFile.relativePath() + "]");
- this.file = inputFile;
- return this;
- }
-
- public CoverageType type() {
- return type;
- }
-
- @Override
- public DefaultCoverage ofType(CoverageType type) {
- Preconditions.checkNotNull(type);
- this.type = type;
- return this;
- }
-
- @Override
- public void save() {
- Preconditions.checkNotNull(this.storage, "No persister on this object");
- Preconditions.checkState(!saved, "This object was already saved");
- Preconditions.checkNotNull(this.file, "File is mandatory on Coverage");
- Preconditions.checkNotNull(this.type, "Type is mandatory on Coverage");
-
- if (!hitsByLine.isEmpty()) {
- new DefaultMeasure<Integer>(storage)
- .onFile(file)
- .forMetric(type.linesToCover())
- .withValue(hitsByLine.size())
- .save();
- new DefaultMeasure<Integer>(storage)
- .onFile(file)
- .forMetric(type.uncoveredLines())
- .withValue(hitsByLine.size() - totalCoveredLines)
- .save();
- new DefaultMeasure<String>(storage)
- .onFile(file)
- .forMetric(type.lineHitsData())
- .withValue(KeyValueFormat.format(hitsByLine))
- .save();
- }
- if (totalConditions > 0) {
- new DefaultMeasure<Integer>(storage)
- .onFile(file)
- .forMetric(type.conditionsToCover())
- .withValue(totalConditions)
- .save();
- new DefaultMeasure<Integer>(storage)
- .onFile(file)
- .forMetric(type.uncoveredConditions())
- .withValue(totalConditions - totalCoveredConditions)
- .save();
- new DefaultMeasure<String>(storage)
- .onFile(file)
- .forMetric(type.coveredConditionsByLine())
- .withValue(KeyValueFormat.format(coveredConditionsByLine))
- .save();
- new DefaultMeasure<String>(storage)
- .onFile(file)
- .forMetric(type.conditionsByLine())
- .withValue(KeyValueFormat.format(conditionsByLine))
- .save();
- }
- this.saved = true;
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverage.java
deleted file mode 100644
index 2199ef002e8..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverage.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test.internal;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
-import org.sonar.api.batch.sensor.internal.DefaultStorable;
-import org.sonar.api.batch.sensor.test.TestCaseCoverage;
-
-import java.util.Collections;
-import java.util.List;
-
-public class DefaultTestCaseCoverage extends DefaultStorable implements TestCaseCoverage {
-
- private InputFile testFile;
- private InputFile mainFile;
- private String name;
- private List<Integer> lines;
-
- public DefaultTestCaseCoverage() {
- super(null);
- }
-
- public DefaultTestCaseCoverage(SensorStorage storage) {
- super(storage);
- }
-
- @Override
- public InputFile testFile() {
- return testFile;
- }
-
- @Override
- public DefaultTestCaseCoverage testFile(InputFile testFile) {
- Preconditions.checkNotNull(testFile, "TestFile cannot be null");
- Preconditions.checkArgument(testFile.type() == InputFile.Type.TEST, "Should be a test file: " + testFile);
- this.testFile = testFile;
- return this;
- }
-
- @Override
- public InputFile coveredFile() {
- return mainFile;
- }
-
- @Override
- public DefaultTestCaseCoverage cover(InputFile mainFile) {
- Preconditions.checkNotNull(mainFile, "InputFile cannot be null");
- Preconditions.checkArgument(mainFile.type() == InputFile.Type.MAIN, "Should be a main file: " + mainFile);
- this.mainFile = mainFile;
- return this;
- }
-
- @Override
- public DefaultTestCaseCoverage testName(String name) {
- Preconditions.checkArgument(StringUtils.isNotBlank(name), "Test name is mandatory and should not be blank");
- this.name = name;
- return this;
- }
-
- @Override
- public String testName() {
- return name;
- }
-
- @Override
- public List<Integer> coveredLines() {
- return Collections.unmodifiableList(lines);
- }
-
- @Override
- public DefaultTestCaseCoverage onLines(List<Integer> lines) {
- Preconditions.checkNotNull(lines, "Lines list cannot be null");
- Preconditions.checkArgument(!lines.isEmpty(), "No need to register test coverage if no line is covered");
- this.lines = lines;
- return this;
- }
-
- @Override
- public void doSave() {
- Preconditions.checkNotNull(testFile, "TestFile is mandatory");
- Preconditions.checkNotNull(mainFile, "MainFile is mandatory");
- Preconditions.checkNotNull(name, "Test name is mandatory");
- Preconditions.checkNotNull(lines, "Lines are mandatory");
- storage.store(this);
- }
-
- // Just for unit tests
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (obj.getClass() != getClass()) {
- return false;
- }
- DefaultTestCaseCoverage rhs = (DefaultTestCaseCoverage) obj;
- return new EqualsBuilder()
- .append(testFile, rhs.testFile)
- .append(name, rhs.name)
- .append(mainFile, rhs.mainFile)
- .append(lines.toArray(), rhs.lines.toArray())
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(13, 43)
- .append(testFile)
- .append(name)
- .append(mainFile)
- .toHashCode();
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecution.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecution.java
deleted file mode 100644
index 550fd83e9ab..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecution.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test.internal;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
-import org.sonar.api.batch.sensor.internal.DefaultStorable;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class DefaultTestCaseExecution extends DefaultStorable implements TestCaseExecution {
-
- private InputFile testFile;
- private String name;
- private Long duration;
- private TestCaseExecution.Status status = Status.OK;
- private String message;
- private TestCaseExecution.Type type = Type.UNIT;
- private String stackTrace;
-
- public DefaultTestCaseExecution() {
- super(null);
- }
-
- public DefaultTestCaseExecution(SensorStorage storage) {
- super(storage);
- }
-
- @Override
- public DefaultTestCaseExecution inTestFile(InputFile testFile) {
- Preconditions.checkNotNull(testFile, "TestFile cannot be null");
- Preconditions.checkArgument(testFile.type() == InputFile.Type.TEST, "Should be a test file: " + testFile);
- this.testFile = testFile;
- return this;
- }
-
- @Override
- public DefaultTestCaseExecution name(String name) {
- Preconditions.checkArgument(StringUtils.isNotBlank(name), "Test name is mandatory and should not be blank");
- this.name = name;
- return this;
- }
-
- @Override
- public DefaultTestCaseExecution durationInMs(long duration) {
- Preconditions.checkArgument(duration >= 0, "Test duration must be positive (got: " + duration + ")");
- this.duration = duration;
- return this;
- }
-
- @Override
- public DefaultTestCaseExecution status(TestCaseExecution.Status status) {
- Preconditions.checkNotNull(status);
- this.status = status;
- return this;
- }
-
- @Override
- public DefaultTestCaseExecution message(@Nullable String message) {
- this.message = message;
- return this;
- }
-
- @Override
- public DefaultTestCaseExecution ofType(TestCaseExecution.Type type) {
- Preconditions.checkNotNull(type);
- this.type = type;
- return this;
- }
-
- @Override
- public DefaultTestCaseExecution stackTrace(@Nullable String stackTrace) {
- this.stackTrace = stackTrace;
- return this;
- }
-
- @Override
- public InputFile testFile() {
- return testFile;
- }
-
- @CheckForNull
- @Override
- public Long durationInMs() {
- return duration;
- }
-
- @Override
- public Type type() {
- return type;
- }
-
- @Override
- public Status status() {
- return status;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @CheckForNull
- @Override
- public String message() {
- return message;
- }
-
- @CheckForNull
- @Override
- public String stackTrace() {
- return stackTrace;
- }
-
- @Override
- public void doSave() {
- Preconditions.checkNotNull(testFile, "TestFile is mandatory");
- Preconditions.checkNotNull(name, "Test name is mandatory");
- storage.store(this);
- }
-
- // Just for unit tests
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (obj.getClass() != getClass()) {
- return false;
- }
- DefaultTestCaseExecution rhs = (DefaultTestCaseExecution) obj;
- return new EqualsBuilder()
- .append(testFile, rhs.testFile)
- .append(name, rhs.name)
- .append(duration, rhs.duration)
- .append(status, rhs.status)
- .append(message, rhs.message)
- .append(type, rhs.type)
- .append(stackTrace, rhs.stackTrace)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(13, 43)
- .append(testFile)
- .append(name)
- .append(duration)
- .append(status)
- .append(message)
- .append(type)
- .append(stackTrace)
- .toHashCode();
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/package-info.java
deleted file mode 100644
index 6074f3891d6..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.
- */
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.sensor.test.internal;
-
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/package-info.java
deleted file mode 100644
index b522765c2d6..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.
- */
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.sensor.test;
-
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverageTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverageTest.java
deleted file mode 100644
index b3c7003cfa4..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultCoverageTest.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test.internal;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
-import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
-import org.sonar.api.batch.sensor.test.Coverage.CoverageType;
-import org.sonar.api.measures.CoreMetrics;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-public class DefaultCoverageTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private InputFile main = new DefaultInputFile("foo", "src/Foo.php").setType(InputFile.Type.MAIN);
-
- @Test
- public void testCreation() {
- DefaultCoverage coverage = new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .lineHits(1, 2)
- .lineHits(2, 5)
- .conditions(1, 2, 1);
-
- assertThat(coverage.file()).isEqualTo(main);
- assertThat(coverage.type()).isEqualTo(CoverageType.UNIT);
- }
-
- @Test
- public void testSaveLines() {
- SensorStorage storage = mock(SensorStorage.class);
- new DefaultCoverage(storage)
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .lineHits(1, 2)
- .lineHits(2, 5)
- .lineHits(3, 0)
- .lineHits(4, 0)
- .save();
-
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.LINES_TO_COVER)
- .withValue(4));
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.UNCOVERED_LINES)
- .withValue(2));
- verify(storage).store(new DefaultMeasure<String>()
- .onFile(main)
- .forMetric(CoreMetrics.COVERAGE_LINE_HITS_DATA)
- .withValue("1=2;2=5;3=0;4=0"));
- verifyNoMoreInteractions(storage);
- }
-
- @Test
- public void testSaveConditions() {
- SensorStorage storage = mock(SensorStorage.class);
- new DefaultCoverage(storage)
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .conditions(1, 2, 1)
- .save();
-
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.CONDITIONS_TO_COVER)
- .withValue(2));
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.UNCOVERED_CONDITIONS)
- .withValue(1));
- verify(storage).store(new DefaultMeasure<String>()
- .onFile(main)
- .forMetric(CoreMetrics.COVERED_CONDITIONS_BY_LINE)
- .withValue("1=1"));
- verify(storage).store(new DefaultMeasure<String>()
- .onFile(main)
- .forMetric(CoreMetrics.CONDITIONS_BY_LINE)
- .withValue("1=2"));
- verifyNoMoreInteractions(storage);
- }
-
- @Test
- public void testSaveLinesAndConditions() {
- SensorStorage storage = mock(SensorStorage.class);
- new DefaultCoverage(storage)
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .lineHits(1, 2)
- .lineHits(2, 5)
- .lineHits(3, 0)
- .lineHits(4, 0)
- .conditions(1, 2, 1)
- .save();
-
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.LINES_TO_COVER)
- .withValue(4));
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.UNCOVERED_LINES)
- .withValue(2));
- verify(storage).store(new DefaultMeasure<String>()
- .onFile(main)
- .forMetric(CoreMetrics.COVERAGE_LINE_HITS_DATA)
- .withValue("1=2;2=5;3=0;4=0"));
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.CONDITIONS_TO_COVER)
- .withValue(2));
- verify(storage).store(new DefaultMeasure<Integer>()
- .onFile(main)
- .forMetric(CoreMetrics.UNCOVERED_CONDITIONS)
- .withValue(1));
- verify(storage).store(new DefaultMeasure<String>()
- .onFile(main)
- .forMetric(CoreMetrics.COVERED_CONDITIONS_BY_LINE)
- .withValue("1=1"));
- verify(storage).store(new DefaultMeasure<String>()
- .onFile(main)
- .forMetric(CoreMetrics.CONDITIONS_BY_LINE)
- .withValue("1=2"));
- verifyNoMoreInteractions(storage);
- }
-
- @Test
- public void dontSaveTwice() {
- SensorStorage storage = mock(SensorStorage.class);
- DefaultCoverage coverage = new DefaultCoverage(storage)
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .lineHits(1, 2)
- .lineHits(2, 5)
- .lineHits(3, 0)
- .lineHits(4, 0);
- coverage.save();
-
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("This object was already saved");
-
- coverage.save();
- }
-
- @Test
- public void fileIsMain() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Coverage is only supported on main files [test/FooTest.php]");
-
- new DefaultCoverage()
- .onFile(new DefaultInputFile("foo", "test/FooTest.php").setType(InputFile.Type.TEST))
- .ofType(CoverageType.UNIT);
- }
-
- @Test
- public void lineHitsValidation() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Line number should be positive and non zero [src/Foo.php:0]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .lineHits(0, 2);
- }
-
- @Test
- public void hitsPositive() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Hits should be positive [src/Foo.php:1]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .lineHits(1, -1);
- }
-
- @Test
- public void hitsNoDuplicate() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Hits already saved on line [src/Foo.php:1]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .lineHits(1, 2)
- .lineHits(1, 1);
- }
-
- @Test
- public void lineConditionValidation() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Line number should be positive and non zero [src/Foo.php:0]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .conditions(0, 2, 2);
- }
-
- @Test
- public void conditionsPositive() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Number of conditions should be positive [src/Foo.php:1]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .conditions(1, -1, 0);
- }
-
- @Test
- public void coveredConditionsPositive() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Number of covered conditions should be positive [src/Foo.php:1]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .conditions(1, 1, -1);
- }
-
- @Test
- public void coveredConditionsVsConditions() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Number of covered conditions can't exceed conditions [src/Foo.php:1]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .conditions(1, 2, 3);
- }
-
- @Test
- public void conditionsNoDuplicate() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Conditions already saved on line [src/Foo.php:1]");
-
- new DefaultCoverage()
- .onFile(main)
- .ofType(CoverageType.UNIT)
- .conditions(1, 4, 3)
- .conditions(1, 4, 2);
- }
-
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverageTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverageTest.java
deleted file mode 100644
index 9512005a6c4..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseCoverageTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test.internal;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-
-import java.util.Arrays;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultTestCaseCoverageTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private InputFile mainFile = new DefaultInputFile("foo", "src/Foo.php").setType(InputFile.Type.MAIN);
- private InputFile testFile = new DefaultInputFile("foo", "test/FooTest.php").setType(InputFile.Type.TEST);
-
- @Test
- public void testCreation() throws Exception {
- DefaultTestCaseCoverage testCaseCoverage = new DefaultTestCaseCoverage()
- .testFile(testFile)
- .testName("myTest")
- .cover(mainFile)
- .onLines(Arrays.asList(1, 2, 3));
-
- assertThat(testCaseCoverage.testName()).isEqualTo("myTest");
- assertThat(testCaseCoverage.testFile()).isEqualTo(testFile);
- assertThat(testCaseCoverage.coveredFile()).isEqualTo(mainFile);
- assertThat(testCaseCoverage.coveredLines()).containsExactly(1, 2, 3);
- }
-
- @Test
- public void testEqualsHashCodeToString() {
- DefaultTestCaseCoverage testCaseCoverage1 = new DefaultTestCaseCoverage()
- .testFile(testFile)
- .testName("myTest")
- .cover(mainFile)
- .onLines(Arrays.asList(1, 2, 3));
- DefaultTestCaseCoverage testCaseCoverage1a = new DefaultTestCaseCoverage()
- .testFile(testFile)
- .testName("myTest")
- .cover(mainFile)
- .onLines(Arrays.asList(1, 2, 3));
- DefaultTestCaseCoverage testCaseCoverage2 = new DefaultTestCaseCoverage()
- .testFile(testFile)
- .testName("myTest2")
- .cover(mainFile)
- .onLines(Arrays.asList(1, 3, 3));
-
- assertThat(testCaseCoverage1).isEqualTo(testCaseCoverage1);
- assertThat(testCaseCoverage1).isEqualTo(testCaseCoverage1a);
- assertThat(testCaseCoverage1).isNotEqualTo(testCaseCoverage2);
- assertThat(testCaseCoverage1).isNotEqualTo(null);
- assertThat(testCaseCoverage1).isNotEqualTo("foo");
-
- assertThat(testCaseCoverage1.toString())
- .isEqualTo(
- "DefaultTestCaseCoverage[testFile=[moduleKey=foo, relative=test/FooTest.php, basedir=null],mainFile=[moduleKey=foo, relative=src/Foo.php, basedir=null],name=myTest,lines=[1, 2, 3]]");
- assertThat(testCaseCoverage1.hashCode()).isEqualTo(testCaseCoverage1a.hashCode());
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecutionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecutionTest.java
deleted file mode 100644
index c1e72389523..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCaseExecutionTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.sensor.test.internal;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.test.TestCaseExecution.Status;
-import org.sonar.api.batch.sensor.test.TestCaseExecution.Type;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultTestCaseExecutionTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private InputFile parent = new DefaultInputFile("foo", "src/Foo.php").setType(InputFile.Type.TEST);
-
- @Test
- public void testCreation() throws Exception {
- DefaultTestCaseExecution testCase = new DefaultTestCaseExecution(null)
- .inTestFile(parent)
- .name("myTest")
- .durationInMs(1)
- .message("message")
- .stackTrace("stack")
- .status(Status.ERROR)
- .ofType(Type.UNIT);
-
- assertThat(testCase.name()).isEqualTo("myTest");
- assertThat(testCase.testFile()).isEqualTo(parent);
- assertThat(testCase.durationInMs()).isEqualTo(1L);
- assertThat(testCase.message()).isEqualTo("message");
- assertThat(testCase.stackTrace()).isEqualTo("stack");
- assertThat(testCase.status()).isEqualTo(Status.ERROR);
- assertThat(testCase.type()).isEqualTo(Type.UNIT);
- }
-
- @Test
- public void testCreationWithDefaultValues() throws Exception {
- DefaultTestCaseExecution testCase = new DefaultTestCaseExecution(null)
- .inTestFile(parent)
- .name("myTest");
-
- assertThat(testCase.name()).isEqualTo("myTest");
- assertThat(testCase.testFile()).isEqualTo(parent);
- assertThat(testCase.durationInMs()).isNull();
- assertThat(testCase.message()).isNull();
- assertThat(testCase.stackTrace()).isNull();
- assertThat(testCase.status()).isEqualTo(Status.OK);
- assertThat(testCase.type()).isEqualTo(Type.UNIT);
- }
-
- @Test
- public void testInvalidDuration() throws Exception {
- DefaultTestCaseExecution builder = new DefaultTestCaseExecution(null)
- .inTestFile(parent)
- .name("myTest");
-
- thrown.expect(IllegalArgumentException.class);
-
- builder.durationInMs(-3);
- }
-
- @Test
- public void testEqualsHashCodeToString() {
- DefaultTestCaseExecution testCase1 = new DefaultTestCaseExecution(null)
- .inTestFile(parent)
- .name("myTest")
- .durationInMs(1)
- .message("message")
- .stackTrace("stack")
- .status(Status.ERROR)
- .ofType(Type.UNIT);
- DefaultTestCaseExecution testCase1a = new DefaultTestCaseExecution(null)
- .inTestFile(parent)
- .name("myTest")
- .durationInMs(1)
- .message("message")
- .stackTrace("stack")
- .status(Status.ERROR)
- .ofType(Type.UNIT);
- DefaultTestCaseExecution testCase2 = new DefaultTestCaseExecution(null)
- .inTestFile(new DefaultInputFile("foo2", "src/Foo.php").setType(InputFile.Type.TEST))
- .name("myTest2")
- .durationInMs(2)
- .message("message2")
- .stackTrace("null")
- .status(Status.FAILURE)
- .ofType(Type.INTEGRATION);
-
- assertThat(testCase1).isEqualTo(testCase1);
- assertThat(testCase1).isEqualTo(testCase1a);
- assertThat(testCase1).isNotEqualTo(testCase2);
- assertThat(testCase1).isNotEqualTo(null);
- assertThat(testCase1).isNotEqualTo("foo");
-
- assertThat(testCase1.toString()).isEqualTo(
- "DefaultTestCaseExecution[testFile=[moduleKey=foo, relative=src/Foo.php, basedir=null],name=myTest,duration=1,status=ERROR,message=message,type=UNIT,stackTrace=stack]");
- assertThat(testCase1.hashCode()).isEqualTo(testCase1a.hashCode());
- }
-
-}