aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-08-10 17:57:57 +0200
committerSonarTech <sonartech@sonarsource.com>2018-08-21 20:21:04 +0200
commit736c4964ccfff0c5a94098804f0d53db4c8da4bb (patch)
tree479c4aff2ed69ac6ff5aa344c88cfecc987ee860 /server
parent35f53579966194ac83fcb0c4b7b570de572ec5cd (diff)
downloadsonarqube-736c4964ccfff0c5a94098804f0d53db4c8da4bb.tar.gz
sonarqube-736c4964ccfff0c5a94098804f0d53db4c8da4bb.zip
SONAR-8368 add line remove changelog when closing issue
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/FunctionExecutor.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java15
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();