diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2014-02-19 12:28:38 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2014-02-25 18:52:32 +0100 |
commit | 23124a18155d030527aa7760b35a0bea5744f9ce (patch) | |
tree | 16cbf1b35ca932b177e42b6a4d068704df643cf0 /sonar-plugin-api/src | |
parent | 0fae2d552337885d31d10348c9900e7ce993dfb4 (diff) | |
download | sonarqube-23124a18155d030527aa7760b35a0bea5744f9ce.tar.gz sonarqube-23124a18155d030527aa7760b35a0bea5744f9ce.zip |
SONAR-4996 Update issue debt to seconds (backend + display)
Diffstat (limited to 'sonar-plugin-api/src')
4 files changed, 24 insertions, 12 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java index 6c13c90c9b9..9904cfaef79 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java @@ -33,11 +33,9 @@ import org.sonar.api.issue.Issue; import org.sonar.api.issue.IssueComment; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; -import org.sonar.api.utils.WorkDuration; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.io.Serializable; import java.util.*; @@ -59,7 +57,7 @@ public class DefaultIssue implements Issue { private String message; private Integer line; private Double effortToFix; - private WorkDuration technicalDebt; + private Long debt; private String status; private String resolution; private String reporter; @@ -196,12 +194,12 @@ public class DefaultIssue implements Issue { * Elapsed time to fix the issue */ @CheckForNull - public WorkDuration technicalDebt() { - return technicalDebt; + public Long debt() { + return debt; } - public DefaultIssue setTechnicalDebt(@Nullable WorkDuration t) { - this.technicalDebt = t; + public DefaultIssue setDebt(@Nullable Long t) { + this.debt = t; return this; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WorkDurationFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WorkDurationFactory.java index 7ecf0d83ba3..89078a964a4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WorkDurationFactory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WorkDurationFactory.java @@ -48,4 +48,11 @@ public final class WorkDurationFactory implements BatchComponent, ServerComponen return settings.getInt(CoreProperties.HOURS_IN_DAY); } + /** + * @since 4.3 + */ + public WorkDuration createFromSeconds(long durationInSeconds) { + return WorkDuration.createFromSeconds(durationInSeconds, hoursInDay); + } + } 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 0df487f777c..9a88011c3c1 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.utils.WorkDuration; import java.text.SimpleDateFormat; import java.util.List; @@ -50,7 +49,7 @@ public class DefaultIssueTest { .setMessage("a message") .setLine(7) .setEffortToFix(1.2d) - .setTechnicalDebt(WorkDuration.createFromValueAndUnit(1, WorkDuration.UNIT.DAYS, 8)) + .setDebt(28800L) .setActionPlanKey("BCDE") .setStatus(Issue.STATUS_CLOSED) .setResolution(Issue.RESOLUTION_FIXED) @@ -78,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.technicalDebt()).isEqualTo(WorkDuration.createFromValueAndUnit(1, WorkDuration.UNIT.DAYS, 8)); + assertThat(issue.debt()).isEqualTo(28800L); 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/utils/WorkDurationFactoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WorkDurationFactoryTest.java index 88e21e9a704..ae289085b8f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WorkDurationFactoryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WorkDurationFactoryTest.java @@ -41,9 +41,9 @@ public class WorkDurationFactoryTest { @Test public void create_from_working_value() throws Exception { // 1 working day -> 8 hours - assertThat(factory.createFromWorkingValue(1, WorkDuration.UNIT.DAYS).toSeconds()).isEqualTo(8*60*60); + assertThat(factory.createFromWorkingValue(1, WorkDuration.UNIT.DAYS).toSeconds()).isEqualTo(8 * 60 * 60); // 8 hours - assertThat(factory.createFromWorkingValue(8, WorkDuration.UNIT.HOURS).toSeconds()).isEqualTo(8*60*60); + assertThat(factory.createFromWorkingValue(8, WorkDuration.UNIT.HOURS).toSeconds()).isEqualTo(8 * 60 * 60); } @Test @@ -53,4 +53,12 @@ public class WorkDurationFactoryTest { assertThat(workDuration.hours()).isEqualTo(0); assertThat(workDuration.minutes()).isEqualTo(1); } + + @Test + public void create_from_seconds() throws Exception { + WorkDuration workDuration = factory.createFromSeconds(8 * 60 * 60L); + assertThat(workDuration.days()).isEqualTo(1); + assertThat(workDuration.hours()).isEqualTo(0); + assertThat(workDuration.minutes()).isEqualTo(0); + } } |