diff options
Diffstat (limited to 'server')
3 files changed, 14 insertions, 7 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java index 6d1577420f9..077bd3b6a1c 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java @@ -64,6 +64,7 @@ public class IssueFieldsSetter { * It should be renamed to 'effort', but it hasn't been done to prevent a massive update in database */ public static final String TECHNICAL_DEBT = "technicalDebt"; + public static final String LINE = "line"; public static final String TAGS = "tags"; private static final Joiner CHANGELOG_TAG_JOINER = Joiner.on(" ").skipNulls(); @@ -140,9 +141,10 @@ public class IssueFieldsSetter { return true; } - public boolean unsetLine(DefaultIssue issue) { + public boolean unsetLine(DefaultIssue issue, IssueChangeContext context) { Integer currentValue = issue.line(); if (currentValue != null) { + issue.setFieldChange(context, LINE, currentValue, ""); issue.setLine(null); issue.setChanged(true); return true; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/FunctionExecutor.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/FunctionExecutor.java index 14b408b4904..4ac65539bc6 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/FunctionExecutor.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/FunctionExecutor.java @@ -90,7 +90,7 @@ public class FunctionExecutor { @Override public Function.Context unsetLine() { - updater.unsetLine(issue); + updater.unsetLine(issue, changeContext); return this; } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java index 5d82ac516a9..5143609c3eb 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java @@ -213,23 +213,28 @@ public class IssueFieldsSetterTest { @Test public void unset_line() { - issue.setLine(new Random().nextInt()); + int line = new Random().nextInt(500); + issue.setLine(line); - boolean updated = underTest.unsetLine(issue); + boolean updated = underTest.unsetLine(issue, context); assertThat(updated).isTrue(); assertThat(issue.isChanged()).isTrue(); assertThat(issue.line()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); - // do not save change - assertThat(issue.currentChange()).isNull(); + assertThat(issue.currentChange()) + .extracting(FieldDiffs::diffs) + .hasSize(1); + FieldDiffs.Diff diff = issue.currentChange().diffs().get("line"); + assertThat(diff.oldValue()).isEqualTo(line); + assertThat(diff.newValue()).isEqualTo(""); } @Test public void unset_line_has_no_effect_if_line_is_already_null() { issue.setLine(null); - boolean updated = underTest.unsetLine(issue); + boolean updated = underTest.unsetLine(issue, context); assertThat(updated).isFalse(); assertThat(issue.line()).isNull(); |