aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test/java/org
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-10-07 13:35:09 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-10-07 13:35:09 +0200
commiteb61eba8a4e2dead826feca34b22ca8fc5fa0ffb (patch)
tree63fb2bccde71e2134d0a99a6e1b3f2f1692f3f75 /sonar-plugin-api/src/test/java/org
parenta559fa67ec15486009e7dccdb79d6f488699dbc2 (diff)
downloadsonarqube-eb61eba8a4e2dead826feca34b22ca8fc5fa0ffb.tar.gz
sonarqube-eb61eba8a4e2dead826feca34b22ca8fc5fa0ffb.zip
SONAR-4716 Replace remediation cost by technical debt in issue
Diffstat (limited to 'sonar-plugin-api/src/test/java/org')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java5
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/TechnicalDebtTest.java73
2 files changed, 76 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java
index 32f164eb4e7..93fba1ecc52 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java
@@ -25,6 +25,7 @@ import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.IssueComment;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.technicaldebt.TechnicalDebt;
import java.text.SimpleDateFormat;
import java.util.List;
@@ -48,7 +49,7 @@ public class DefaultIssueTest {
.setMessage("a message")
.setLine(7)
.setEffortToFix(1.2d)
- .setRemediationCost(1L)
+ .setTechnicalDebt(TechnicalDebt.of(1, 0, 0))
.setActionPlanKey("BCDE")
.setStatus(Issue.STATUS_CLOSED)
.setResolution(Issue.RESOLUTION_FIXED)
@@ -76,7 +77,7 @@ public class DefaultIssueTest {
assertThat(issue.message()).isEqualTo("a message");
assertThat(issue.line()).isEqualTo(7);
assertThat(issue.effortToFix()).isEqualTo(1.2d);
- assertThat(issue.remediationCost()).isEqualTo(1L);
+ assertThat(issue.technicalDebt()).isEqualTo(TechnicalDebt.of(1, 0, 0));
assertThat(issue.actionPlanKey()).isEqualTo("BCDE");
assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/TechnicalDebtTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/TechnicalDebtTest.java
new file mode 100644
index 00000000000..5a51722c98e
--- /dev/null
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/TechnicalDebtTest.java
@@ -0,0 +1,73 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.technicaldebt;
+
+import org.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class TechnicalDebtTest {
+
+ @Test
+ public void from_long_on_simple_values(){
+ checkTimes(TechnicalDebt.fromLong(1L), 0, 0, 1);
+ checkTimes(TechnicalDebt.fromLong(100L), 0, 1, 0);
+ checkTimes(TechnicalDebt.fromLong(10000L), 1, 0, 0);
+ }
+
+ @Test
+ public void from_long_on_complex_values(){
+ checkTimes(TechnicalDebt.fromLong(10101L), 1, 1, 1);
+ checkTimes(TechnicalDebt.fromLong(101L), 0, 1, 1);
+ checkTimes(TechnicalDebt.fromLong(10001L), 1, 0, 1);
+ checkTimes(TechnicalDebt.fromLong(10100L), 1, 1, 0);
+
+ checkTimes(TechnicalDebt.fromLong(112233L), 11, 22, 33);
+ }
+
+ @Test
+ public void to_long(){
+ assertThat(TechnicalDebt.of(1, 1, 1).toLong()).isEqualTo(10101L);
+ }
+
+ @Test
+ public void test_equals_and_hashCode() throws Exception {
+ TechnicalDebt oneMinute = TechnicalDebt.fromLong(1L);
+ TechnicalDebt oneHours = TechnicalDebt.fromLong(100L);
+ TechnicalDebt oneDay = TechnicalDebt.fromLong(10000L);
+
+ assertThat(oneMinute).isEqualTo(oneMinute);
+ assertThat(oneMinute).isEqualTo(TechnicalDebt.fromLong(1L));
+ assertThat(oneHours).isEqualTo(TechnicalDebt.fromLong(100L));
+ assertThat(oneDay).isEqualTo(TechnicalDebt.fromLong(10000L));
+
+ assertThat(oneMinute).isNotEqualTo(oneHours);
+ assertThat(oneHours).isNotEqualTo(oneDay);
+
+ assertThat(oneMinute.hashCode()).isEqualTo(oneMinute.hashCode());
+ }
+
+ private void checkTimes(TechnicalDebt technicalDebt, int expectedDays, int expectedHours, int expectedMinutes){
+ assertThat(technicalDebt.days()).isEqualTo(expectedDays);
+ assertThat(technicalDebt.hours()).isEqualTo(expectedHours);
+ assertThat(technicalDebt.minutes()).isEqualTo(expectedMinutes);
+ }
+
+}