aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-01-30 18:31:16 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-01-30 18:36:39 +0100
commit04e8a2dc3dbd73170008e6eb9bd02285c3eac9ff (patch)
treeafa6946c148131733bb74ed28103b54958b6a9e2 /sonar-plugin-api
parent5c9ee1b4ed291f2cd2465769b9a4d57dec25976c (diff)
downloadsonarqube-04e8a2dc3dbd73170008e6eb9bd02285c3eac9ff.tar.gz
sonarqube-04e8a2dc3dbd73170008e6eb9bd02285c3eac9ff.zip
SONAR-2501 add preconditions and refactor some method names
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/Cover.java (renamed from sonar-plugin-api/src/main/java/org/sonar/api/test/CoveredTestable.java)8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java10
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/exception/IllegalDurationException.java26
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java26
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestException.java30
9 files changed, 105 insertions, 20 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/CoveredTestable.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/Cover.java
index a52d7477664..313f84a9b07 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/CoveredTestable.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/Cover.java
@@ -19,11 +19,13 @@
*/
package org.sonar.api.test;
-import java.util.Collection;
+import java.util.List;
-public interface CoveredTestable {
+public interface Cover {
TestCase testCase();
+
Testable testable();
- Collection<Integer> lines();
+
+ List<Integer> lines();
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java
index 7a7f9dcd2de..ee258383d9f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java
@@ -34,5 +34,5 @@ public interface MutableTestCase extends TestCase {
MutableTestCase setStackTrace(String s);
- void covers(Testable testable, List<Integer> lines);
+ void setCover(Testable testable, List<Integer> lines);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java
index 15d7e8f246f..7fefb851de8 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java
@@ -23,6 +23,7 @@ import org.sonar.api.component.MutablePerspective;
public interface MutableTestPlan extends TestPlan<MutableTestCase>, MutablePerspective {
- MutableTestCase addTestCase(String key);
+ MutableTestPlan setType(String s);
+ MutableTestCase addTestCase(String key);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java
index 4fb387ba070..75ad3fb7073 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java
@@ -19,18 +19,10 @@
*/
package org.sonar.api.test;
-import java.util.Collection;
-
public interface TestCase {
- String TYPE_UNIT = "unit";
- String TYPE_INTEGRATION = "integration";
-
String STATUS_PASS = "pass";
String STATUS_FAIL = "fail";
- // unit test/integration test/...
- String type();
-
/**
* Duration in milliseconds
*/
@@ -52,9 +44,9 @@ public interface TestCase {
TestPlan testPlan();
- boolean hasCoveredLines();
+ boolean doesCover();
int countCoveredLines();
- Collection<CoveredTestable> coveredTestable();
+ Iterable<Cover> covers();
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java
index c6c6f1827ee..1c334e2442b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java
@@ -24,5 +24,13 @@ import org.sonar.api.component.Perspective;
import java.util.List;
public interface TestPlan<T extends TestCase> extends Perspective {
- List<T> testCases();
+ String TYPE_UNIT = "unit";
+ String TYPE_INTEGRATION = "integration";
+
+ // unit test/integration test/...
+ String type();
+
+ Iterable<T> testCases();
+
+ T testCaseByKey(String key);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java
index 78a96edcb14..a4eb95306aa 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java
@@ -21,17 +21,17 @@ package org.sonar.api.test;
import org.sonar.api.component.Perspective;
-import java.util.Collection;
+import java.util.List;
import java.util.SortedSet;
public interface Testable extends Perspective {
- Collection<TestCase> testCases();
+ List<TestCase> testCases();
int countTestCasesOfLine(int line);
- Collection<TestCase> testCasesOfLine(int line);
+ List<TestCase> testCasesOfLine(int line);
- SortedSet<Long> testedLines();
+ SortedSet<Integer> testedLines();
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/IllegalDurationException.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/IllegalDurationException.java
new file mode 100644
index 00000000000..41655e5bdbe
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/IllegalDurationException.java
@@ -0,0 +1,26 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.test.exception;
+
+public class IllegalDurationException extends TestException {
+ public IllegalDurationException(String message) {
+ super(message);
+ }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java
new file mode 100644
index 00000000000..ff1453b9ba8
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestCaseAlreadyExistsException.java
@@ -0,0 +1,26 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.test.exception;
+
+public class TestCaseAlreadyExistsException extends TestException {
+ public TestCaseAlreadyExistsException(String componentKey, String testCaseKey) {
+ super(String.format("Test case already exists for %s: %s", componentKey, testCaseKey));
+ }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestException.java b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestException.java
new file mode 100644
index 00000000000..d3711c534b7
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/test/exception/TestException.java
@@ -0,0 +1,30 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.test.exception;
+
+public class TestException extends RuntimeException {
+ public TestException(String message) {
+ super(message);
+ }
+
+ public TestException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}