aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-03 11:45:52 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-03 11:56:21 +0200
commit9fc6df0d576e72ae3a6746868684d2802a1291b8 (patch)
tree9b2c7f492241a6c0a134094ca4281463cbcc8935 /sonar-plugin-api/src
parent95820442b90fc0642453e51c9233bae36a3b28db (diff)
downloadsonarqube-9fc6df0d576e72ae3a6746868684d2802a1291b8.tar.gz
sonarqube-9fc6df0d576e72ae3a6746868684d2802a1291b8.zip
SONAR-5056 When update rule, if sub characteristic or remediation function is different from default values, update both overridden values
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java5
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java10
2 files changed, 14 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
index f0cbd4e0638..cc8d58b2002 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
@@ -37,7 +37,10 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
private final String coefficient;
private final String offset;
- public DefaultDebtRemediationFunction(Type type, @Nullable String coefficient, @Nullable String offset) {
+ public DefaultDebtRemediationFunction(@Nullable Type type, @Nullable String coefficient, @Nullable String offset) {
+ if (type == null) {
+ throw new IllegalArgumentException("Remediation function type cannot be null");
+ }
this.type = type;
this.coefficient = sanitizeValue("coefficient", coefficient);
this.offset = sanitizeValue("offset", offset);
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java
index 8bdefe18651..b165c6b1556 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/DefaultDebtRemediationFunctionTest.java
@@ -61,6 +61,16 @@ public class DefaultDebtRemediationFunctionTest {
}
@Test
+ public void fail_to_when_no_type() {
+ try {
+ new DefaultDebtRemediationFunction(null, "5min", "10h");
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertThat(e).hasMessage("Remediation function type cannot be null");
+ }
+ }
+
+ @Test
public void fail_to_create_linear_when_no_coefficient() {
try {
new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, null, "10h");