]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 fix bug in IssueUpdater#setEffortToFix()
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 22 May 2013 06:43:26 +0000 (08:43 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 22 May 2013 06:43:26 +0000 (08:43 +0200)
sonar-core/src/main/java/org/sonar/core/issue/IssueUpdater.java
sonar-core/src/test/java/org/sonar/core/issue/IssueUpdaterTest.java

index 0c9daf6538b8c60f0fdd8be77b3074ff8db365a1..eed467aa64745fe03b5d46e1b72a11e8960b321e 100644 (file)
@@ -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) {
index 31bed11603c617c48c86086d42c07f33b89feb6c..b9db96810f4a93b2ca7d576f4ddd6bda19bc602e 100644 (file)
@@ -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);
+  }
 }