From a0e127fc2ca9c19a562d3e53097f0cc7fc6c261c Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 22 May 2013 08:43:26 +0200 Subject: [PATCH] SONAR-3755 fix bug in IssueUpdater#setEffortToFix() --- .../java/org/sonar/core/issue/IssueUpdater.java | 6 ++++-- .../org/sonar/core/issue/IssueUpdaterTest.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueUpdater.java b/sonar-core/src/main/java/org/sonar/core/issue/IssueUpdater.java index 0c9daf6538b..eed467aa647 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/IssueUpdater.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/IssueUpdater.java @@ -133,12 +133,14 @@ public class IssueUpdater implements BatchComponent, ServerComponent { } } - public void setEffortToFix(DefaultIssue issue, @Nullable Double d, IssueChangeContext context) { - if (!Objects.equal(d, issue.closeDate())) { + public boolean setEffortToFix(DefaultIssue issue, @Nullable Double d, IssueChangeContext context) { + if (!Objects.equal(d, issue.effortToFix())) { issue.setEffortToFix(d); issue.setUpdateDate(context.date()); issue.setChanged(true); + return true; } + return false; } public boolean setAttribute(DefaultIssue issue, String key, @Nullable String value, IssueChangeContext context) { diff --git a/sonar-core/src/test/java/org/sonar/core/issue/IssueUpdaterTest.java b/sonar-core/src/test/java/org/sonar/core/issue/IssueUpdaterTest.java index 31bed11603c..b9db96810f4 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/IssueUpdaterTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/IssueUpdaterTest.java @@ -232,4 +232,21 @@ public class IssueUpdaterTest { assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("ABCD"); } + + @Test + public void should_set_effort_to_fix() throws Exception { + boolean updated = updater.setEffortToFix(issue, 3.14, context); + assertThat(updated).isTrue(); + assertThat(issue.isChanged()).isTrue(); + assertThat(issue.effortToFix()).isEqualTo(3.14); + } + + @Test + public void should_not_set_effort_to_fix_if_unchanged() throws Exception { + issue.setEffortToFix(3.14); + boolean updated = updater.setEffortToFix(issue, 3.14, context); + assertThat(updated).isFalse(); + assertThat(issue.isChanged()).isFalse(); + assertThat(issue.effortToFix()).isEqualTo(3.14); + } } -- 2.39.5