From b5116218aebe1ae7ca6f3abcd77b507ae3cb5131 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 6 Nov 2013 14:38:40 +0100 Subject: Rename TechnicalDebt class name to WorkDayDuration and move it to issue internal package --- .../sonar/api/issue/internal/DefaultIssueTest.java | 5 +- .../api/issue/internal/WorkDayDurationTest.java | 73 ++++++++++++++++++++++ .../sonar/api/technicaldebt/TechnicalDebtTest.java | 73 ---------------------- 3 files changed, 75 insertions(+), 76 deletions(-) create mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/WorkDayDurationTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/TechnicalDebtTest.java (limited to 'sonar-plugin-api/src/test') 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 93fba1ecc52..2cd8cdbdfda 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,7 +25,6 @@ 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; @@ -49,7 +48,7 @@ public class DefaultIssueTest { .setMessage("a message") .setLine(7) .setEffortToFix(1.2d) - .setTechnicalDebt(TechnicalDebt.of(1, 0, 0)) + .setTechnicalDebt(WorkDayDuration.of(1, 0, 0)) .setActionPlanKey("BCDE") .setStatus(Issue.STATUS_CLOSED) .setResolution(Issue.RESOLUTION_FIXED) @@ -77,7 +76,7 @@ public class DefaultIssueTest { assertThat(issue.message()).isEqualTo("a message"); assertThat(issue.line()).isEqualTo(7); assertThat(issue.effortToFix()).isEqualTo(1.2d); - assertThat(issue.technicalDebt()).isEqualTo(TechnicalDebt.of(1, 0, 0)); + assertThat(issue.technicalDebt()).isEqualTo(WorkDayDuration.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/issue/internal/WorkDayDurationTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/WorkDayDurationTest.java new file mode 100644 index 00000000000..ccff88c8624 --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/WorkDayDurationTest.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.issue.internal; + +import org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +public class WorkDayDurationTest { + + @Test + public void from_long_on_simple_values(){ + checkTimes(WorkDayDuration.fromLong(1L), 0, 0, 1); + checkTimes(WorkDayDuration.fromLong(100L), 0, 1, 0); + checkTimes(WorkDayDuration.fromLong(10000L), 1, 0, 0); + } + + @Test + public void from_long_on_complex_values(){ + checkTimes(WorkDayDuration.fromLong(10101L), 1, 1, 1); + checkTimes(WorkDayDuration.fromLong(101L), 0, 1, 1); + checkTimes(WorkDayDuration.fromLong(10001L), 1, 0, 1); + checkTimes(WorkDayDuration.fromLong(10100L), 1, 1, 0); + + checkTimes(WorkDayDuration.fromLong(112233L), 11, 22, 33); + } + + @Test + public void to_long(){ + assertThat(WorkDayDuration.of(1, 1, 1).toLong()).isEqualTo(10101L); + } + + @Test + public void test_equals_and_hashCode() throws Exception { + WorkDayDuration oneMinute = WorkDayDuration.fromLong(1L); + WorkDayDuration oneHours = WorkDayDuration.fromLong(100L); + WorkDayDuration oneDay = WorkDayDuration.fromLong(10000L); + + assertThat(oneMinute).isEqualTo(oneMinute); + assertThat(oneMinute).isEqualTo(WorkDayDuration.fromLong(1L)); + assertThat(oneHours).isEqualTo(WorkDayDuration.fromLong(100L)); + assertThat(oneDay).isEqualTo(WorkDayDuration.fromLong(10000L)); + + assertThat(oneMinute).isNotEqualTo(oneHours); + assertThat(oneHours).isNotEqualTo(oneDay); + + assertThat(oneMinute.hashCode()).isEqualTo(oneMinute.hashCode()); + } + + private void checkTimes(WorkDayDuration technicalDebt, int expectedDays, int expectedHours, int expectedMinutes){ + assertThat(technicalDebt.days()).isEqualTo(expectedDays); + assertThat(technicalDebt.hours()).isEqualTo(expectedHours); + assertThat(technicalDebt.minutes()).isEqualTo(expectedMinutes); + } + +} 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 deleted file mode 100644 index 5a51722c98e..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/technicaldebt/TechnicalDebtTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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); - } - -} -- cgit v1.2.3