aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-04 11:47:15 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-04 11:47:23 +0200
commit79ebf35daa3acad4ec270ab193e1506d57f9afed (patch)
tree4ff02c5c132ef97e0cb95c1440ac978586ba4627 /sonar-plugin-api
parenta3d9f8a4b36e3370e96834bdd8aaecdadd27b1fe (diff)
downloadsonarqube-79ebf35daa3acad4ec270ab193e1506d57f9afed.tar.gz
sonarqube-79ebf35daa3acad4ec270ab193e1506d57f9afed.zip
Create a specific unit test of declaring rules with technical debt
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java33
1 files changed, 24 insertions, 9 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java
index 3a028382d3c..1027e8ba3fc 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java
@@ -65,17 +65,14 @@ public class RulesDefinitionTest {
@Test
public void define_rules() {
RulesDefinition.NewRepository newRepo = context.createRepository("findbugs", "java");
- RulesDefinition.NewRule newRule = newRepo.createRule("NPE")
+ newRepo.createRule("NPE")
.setName("Detect NPE")
.setHtmlDescription("Detect <code>java.lang.NullPointerException</code>")
.setSeverity(Severity.BLOCKER)
.setInternalKey("/something")
.setStatus(RuleStatus.BETA)
- .setDebtSubCharacteristic("COMPILER")
- .setEffortToFixDescription("squid.S115.effortToFix")
.setTags("one", "two")
.addTags("two", "three", "four");
- newRule.setDebtRemediationFunction(newRule.debtRemediationFunctions().linearWithOffset("1h", "10min"));
newRepo.createRule("ABC").setName("ABC").setHtmlDescription("ABC");
newRepo.done();
@@ -93,11 +90,6 @@ public class RulesDefinitionTest {
assertThat(rule.internalKey()).isEqualTo("/something");
assertThat(rule.template()).isFalse();
assertThat(rule.status()).isEqualTo(RuleStatus.BETA);
- assertThat(rule.debtSubCharacteristic()).isEqualTo("COMPILER");
- assertThat(rule.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
- assertThat(rule.debtRemediationFunction().coefficient()).isEqualTo("1h");
- assertThat(rule.debtRemediationFunction().offset()).isEqualTo("10min");
- assertThat(rule.effortToFixDescription()).isEqualTo("squid.S115.effortToFix");
assertThat(rule.toString()).isEqualTo("[repository=findbugs, key=NPE]");
assertThat(rule.repository()).isSameAs(repo);
@@ -108,6 +100,29 @@ public class RulesDefinitionTest {
}
@Test
+ public void define_rules_with_technical_debt() {
+ RulesDefinition.NewRepository newRepo = context.createRepository("common-java", "java");
+ RulesDefinition.NewRule newRule = newRepo.createRule("InsufficientBranchCoverage")
+ .setName("Insufficient branch coverage")
+ .setHtmlDescription("Insufficient branch coverage by unit tests")
+ .setSeverity(Severity.MAJOR)
+ .setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.UNIT_TESTS)
+ .setEffortToFixDescription("Effort to test one uncovered branch");
+ newRule.setDebtRemediationFunction(newRule.debtRemediationFunctions().linearWithOffset("1h", "10min"));
+ newRepo.done();
+
+ RulesDefinition.Repository repo = context.repository("common-java");
+ assertThat(repo.rules()).hasSize(1);
+
+ RulesDefinition.Rule rule = repo.rule("InsufficientBranchCoverage");
+ assertThat(rule.debtSubCharacteristic()).isEqualTo("UNIT_TESTS");
+ assertThat(rule.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET);
+ assertThat(rule.debtRemediationFunction().coefficient()).isEqualTo("1h");
+ assertThat(rule.debtRemediationFunction().offset()).isEqualTo("10min");
+ assertThat(rule.effortToFixDescription()).isEqualTo("Effort to test one uncovered branch");
+ }
+
+ @Test
public void define_rule_with_default_fields() {
RulesDefinition.NewRepository newFindbugs = context.createRepository("findbugs", "java");
newFindbugs.createRule("NPE").setName("NPE").setHtmlDescription("NPE");