diff options
author | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-08-09 11:40:12 +0200 |
---|---|---|
committer | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-08-09 11:40:12 +0200 |
commit | b9ecdcaecb29b4fa15e7318a5a700da60b637987 (patch) | |
tree | 5da2686b880ee440ab0929071e8439db5d417d42 /sonar-plugin-api/src | |
parent | c8d4102872968607dd5daf29940be30011b0af6c (diff) | |
download | sonarqube-b9ecdcaecb29b4fa15e7318a5a700da60b637987.tar.gz sonarqube-b9ecdcaecb29b4fa15e7318a5a700da60b637987.zip |
SONAR-4375 Improve issue changelog display by returning names instead of keys for users and action plans
Diffstat (limited to 'sonar-plugin-api/src')
3 files changed, 22 insertions, 13 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java index 12f4a5c3fdd..1a59ccc8fd9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java @@ -20,6 +20,7 @@ package org.sonar.api.issue; import org.sonar.api.BatchExtension; +import org.sonar.api.user.User; import javax.annotation.Nullable; @@ -47,8 +48,14 @@ public interface IssueHandler extends BatchExtension { Context setAttribute(String key, @Nullable String value); + /** + * @deprecated since 4.0 + */ + @Deprecated Context assign(@Nullable String login); + Context assign(@Nullable User user); + Context addComment(String text); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java index 9d954cbd77a..386de94e09e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java @@ -30,7 +30,7 @@ import java.util.Date; import java.util.Map; /** - * PLUGINS MUST NOT BE USED THIS CLASS, EXCEPT FOR UNIT TESTING. + * PLUGINS MUST NOT USE THIS CLASS, EXCEPT FOR UNIT TESTING. * * @since 3.6 */ @@ -118,13 +118,15 @@ public class FieldDiffs implements Serializable { String[] values = keyValues[1].split("\\|"); String oldValue = ""; String newValue = ""; - if (values.length > 0) { + if(values.length == 1) { + newValue = Strings.nullToEmpty(values[0]); + } else if(values.length == 2) { oldValue = Strings.nullToEmpty(values[0]); - } - if (values.length > 1) { newValue = Strings.nullToEmpty(values[1]); } diffs.setDiff(keyValues[0], oldValue, newValue); + } else { + diffs.setDiff(keyValues[0], "", ""); } } } @@ -155,11 +157,11 @@ public class FieldDiffs implements Serializable { public String toString() { //TODO escape , and | characters StringBuilder sb = new StringBuilder(); - if (oldValue != null) { - sb.append(oldValue.toString()); - } - sb.append('|'); - if (newValue != null) { + if(newValue != null) { + if(oldValue != null) { + sb.append(oldValue.toString()); + sb.append('|'); + } sb.append(newValue.toString()); } return sb.toString(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/FieldDiffsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/FieldDiffsTest.java index e8faaa5821d..e6f31fafb69 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/FieldDiffsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/FieldDiffsTest.java @@ -68,9 +68,9 @@ public class FieldDiffsTest { @Test public void test_toString_with_null_values() throws Exception { diffs.setDiff("severity", null, "INFO"); - diffs.setDiff("resolution", "OPEN", null); + diffs.setDiff("assignee", "user1", null); - assertThat(diffs.toString()).isEqualTo("severity=|INFO,resolution=OPEN|"); + assertThat(diffs.toString()).isEqualTo("severity=INFO,assignee="); } @Test @@ -89,7 +89,7 @@ public class FieldDiffsTest { @Test public void test_parse_empty_values() throws Exception { - diffs = FieldDiffs.parse("severity=|INFO,resolution=OPEN|"); + diffs = FieldDiffs.parse("severity=INFO,resolution="); assertThat(diffs.diffs()).hasSize(2); FieldDiffs.Diff diff = diffs.diffs().get("severity"); @@ -97,7 +97,7 @@ public class FieldDiffsTest { assertThat(diff.newValue()).isEqualTo("INFO"); diff = diffs.diffs().get("resolution"); - assertThat(diff.oldValue()).isEqualTo("OPEN"); + assertThat(diff.oldValue()).isEqualTo(""); assertThat(diff.newValue()).isEqualTo(""); } |