aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt
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/sonar/api/technicaldebt
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/sonar/api/technicaldebt')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/TechnicalDebtTest.java73
1 files changed, 73 insertions, 0 deletions
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);
+ }
+
+}