diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-06-04 15:54:15 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-06-04 15:58:18 +0200 |
commit | 2b90c6d9deb4fafe99ae7c88cdc67d02cd1d2d76 (patch) | |
tree | f07399be46b8d3032732e976134df5008bc808f9 /sonar-core | |
parent | ea4b51a3ad43e7d6ce6b18b9eac32fd45e0cc367 (diff) | |
download | sonarqube-2b90c6d9deb4fafe99ae7c88cdc67d02cd1d2d76.tar.gz sonarqube-2b90c6d9deb4fafe99ae7c88cdc67d02cd1d2d76.zip |
SONAR-4284 Display a changelog in the Issue detail page
Diffstat (limited to 'sonar-core')
11 files changed, 86 insertions, 66 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java index f10e4da4ff6..3d2013e6a41 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java @@ -87,7 +87,7 @@ public class IssueNotifications implements BatchComponent, ServerComponent { @CheckForNull private Notification createChangeNotification(DefaultIssue issue, IssueChangeContext context, Rule rule, Component project, @Nullable Component component, @Nullable String comment) { - if (comment == null && (issue.diffs() == null || issue.diffs().diffs().isEmpty())) { + if (comment == null && (issue.currentChange() == null || issue.currentChange().diffs().isEmpty())) { return null; } Notification notification = newNotification(project, "issue-changes"); @@ -105,7 +105,7 @@ public class IssueNotifications implements BatchComponent, ServerComponent { notification.setFieldValue("comment", comment); } - FieldDiffs diffs = issue.diffs(); + FieldDiffs diffs = issue.currentChange(); if (diffs != null) { for (Map.Entry<String, FieldDiffs.Diff> entry : diffs.diffs().entrySet()) { String type = entry.getKey(); 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 66bda0c6e28..a91d401e0df 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 @@ -41,7 +41,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { throw new IllegalStateException("Severity can't be changed"); } if (!Objects.equal(severity, issue.severity())) { - issue.setFieldDiff(context, "severity", issue.severity(), severity); + issue.setFieldChange(context, "severity", issue.severity(), severity); issue.setSeverity(severity); issue.setUpdateDate(context.date()); issue.setChanged(true); @@ -58,7 +58,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { public boolean setManualSeverity(DefaultIssue issue, String severity, IssueChangeContext context) { if (!issue.manualSeverity() || !Objects.equal(severity, issue.severity())) { - issue.setFieldDiff(context, "severity", issue.severity(), severity); + issue.setFieldChange(context, "severity", issue.severity(), severity); issue.setSeverity(severity); issue.setManualSeverity(true); issue.setUpdateDate(context.date()); @@ -71,7 +71,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { public boolean assign(DefaultIssue issue, @Nullable String assignee, IssueChangeContext context) { String sanitizedAssignee = StringUtils.defaultIfBlank(assignee, null); if (!Objects.equal(sanitizedAssignee, issue.assignee())) { - issue.setFieldDiff(context, "assignee", issue.assignee(), sanitizedAssignee); + issue.setFieldChange(context, "assignee", issue.assignee(), sanitizedAssignee); issue.setAssignee(sanitizedAssignee); issue.setUpdateDate(context.date()); issue.setChanged(true); @@ -97,7 +97,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { public boolean setResolution(DefaultIssue issue, @Nullable String resolution, IssueChangeContext context) { if (!Objects.equal(resolution, issue.resolution())) { - issue.setFieldDiff(context, "resolution", issue.resolution(), resolution); + issue.setFieldChange(context, "resolution", issue.resolution(), resolution); issue.setResolution(resolution); issue.setUpdateDate(context.date()); issue.setChanged(true); @@ -108,7 +108,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { public boolean setStatus(DefaultIssue issue, String status, IssueChangeContext context) { if (!Objects.equal(status, issue.status())) { - issue.setFieldDiff(context, "status", issue.status(), status); + issue.setFieldChange(context, "status", issue.status(), status); issue.setStatus(status); issue.setUpdateDate(context.date()); issue.setChanged(true); @@ -119,7 +119,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { public boolean setAuthorLogin(DefaultIssue issue, @Nullable String authorLogin, IssueChangeContext context) { if (!Objects.equal(authorLogin, issue.authorLogin())) { - issue.setFieldDiff(context, "author", issue.authorLogin(), authorLogin); + issue.setFieldChange(context, "author", issue.authorLogin(), authorLogin); issue.setAuthorLogin(authorLogin); issue.setUpdateDate(context.date()); issue.setChanged(true); @@ -177,7 +177,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { public boolean setAttribute(DefaultIssue issue, String key, @Nullable String value, IssueChangeContext context) { String oldValue = issue.attribute(key); if (!Objects.equal(oldValue, value)) { - issue.setFieldDiff(context, key, oldValue, value); + issue.setFieldChange(context, key, oldValue, value); issue.setAttribute(key, value); issue.setUpdateDate(context.date()); issue.setChanged(true); @@ -189,7 +189,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { public boolean plan(DefaultIssue issue, @Nullable String actionPlanKey, IssueChangeContext context) { String sanitizedActionPlanKey = StringUtils.defaultIfBlank(actionPlanKey, null); if (!Objects.equal(sanitizedActionPlanKey, issue.actionPlanKey())) { - issue.setFieldDiff(context, "actionPlanKey", issue.actionPlanKey(), sanitizedActionPlanKey); + issue.setFieldChange(context, "actionPlanKey", issue.actionPlanKey(), sanitizedActionPlanKey); issue.setActionPlanKey(sanitizedActionPlanKey); issue.setUpdateDate(context.date()); issue.setChanged(true); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java index c06f5d61b8e..3061586f253 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java @@ -26,11 +26,13 @@ import org.apache.ibatis.session.SqlSession; import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; import org.sonar.api.issue.internal.DefaultIssueComment; +import org.sonar.api.issue.internal.FieldDiffs; import org.sonar.core.persistence.MyBatis; import javax.annotation.CheckForNull; - +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; /** @@ -45,15 +47,21 @@ public class IssueChangeDao implements BatchComponent, ServerComponent { } public List<DefaultIssueComment> selectCommentsByIssues(SqlSession session, Collection<String> issueKeys) { - return selectByIssuesAndType(session, issueKeys, IssueChangeDto.TYPE_COMMENT); + List<DefaultIssueComment> comments = Lists.newArrayList(); + for (IssueChangeDto dto : selectByIssuesAndType(session, issueKeys, IssueChangeDto.TYPE_COMMENT)) { + comments.add(dto.toComment()); + } + return comments; } - public List<IssueChangeDto> selectIssueChangelog(String issueKey) { + public List<FieldDiffs> selectChangelogByIssue(String issueKey) { SqlSession session = mybatis.openSession(); try { - IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class); - return mapper.selectByIssue(issueKey); - + List<FieldDiffs> result = Lists.newArrayList(); + for (IssueChangeDto dto : selectByIssuesAndType(session, Arrays.asList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE)) { + result.add(dto.toFieldDiffs()); + } + return result; } finally { MyBatis.closeQuietly(session); } @@ -72,17 +80,13 @@ public class IssueChangeDao implements BatchComponent, ServerComponent { } } - List<DefaultIssueComment> selectByIssuesAndType(SqlSession session, Collection<String> issueKeys, String changeType) { + List<IssueChangeDto> selectByIssuesAndType(SqlSession session, Collection<String> issueKeys, String changeType) { Preconditions.checkArgument(issueKeys.size() < 1000, "Number of issue keys is greater than or equal 1000"); - List<DefaultIssueComment> result = Lists.newArrayList(); - if (!issueKeys.isEmpty()) { - IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class); - List<IssueChangeDto> dtos = mapper.selectByIssuesAndType(issueKeys, changeType); - for (IssueChangeDto dto : dtos) { - result.add(dto.toComment()); - } + if (issueKeys.isEmpty()) { + return Collections.emptyList(); } - return result; + IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class); + return mapper.selectByIssuesAndType(issueKeys, changeType); } public boolean delete(String key) { diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java index eddc19c23f7..b8287a83655 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java @@ -88,7 +88,7 @@ public abstract class IssueStorage { mapper.insert(changeDto); } } - FieldDiffs diffs = issue.diffs(); + FieldDiffs diffs = issue.currentChange(); if (diffs != null) { IssueChangeDto changeDto = IssueChangeDto.of(issue.key(), diffs); mapper.insert(changeDto); diff --git a/sonar-core/src/main/java/org/sonar/core/user/DefaultUserFinder.java b/sonar-core/src/main/java/org/sonar/core/user/DefaultUserFinder.java index 9773d17f26e..2ddfb1a76c9 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/DefaultUserFinder.java +++ b/sonar-core/src/main/java/org/sonar/core/user/DefaultUserFinder.java @@ -25,6 +25,7 @@ import org.sonar.api.user.UserFinder; import org.sonar.api.user.UserQuery; import javax.annotation.CheckForNull; +import java.util.Collection; import java.util.List; /** @@ -57,7 +58,7 @@ public class DefaultUserFinder implements UserFinder { return toUsers(dtos); } - private List<User> toUsers(List<UserDto> dtos) { + private List<User> toUsers(Collection<UserDto> dtos) { List<User> users = Lists.newArrayList(); for (UserDto dto : dtos) { users.add(dto.toUser()); diff --git a/sonar-core/src/main/java/org/sonar/core/user/UserDao.java b/sonar-core/src/main/java/org/sonar/core/user/UserDao.java index 01bc6aae388..32b3978e6b0 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/UserDao.java +++ b/sonar-core/src/main/java/org/sonar/core/user/UserDao.java @@ -25,6 +25,7 @@ import org.sonar.api.user.UserQuery; import org.sonar.core.persistence.MyBatis; import javax.annotation.CheckForNull; +import java.util.Collection; import java.util.List; /** diff --git a/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java b/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java index eae906010a9..7f14933a985 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java @@ -74,8 +74,8 @@ public class IssueNotificationsTest { .setMessage("the message") .setKey("ABCDE") .setAssignee("freddy") - .setFieldDiff(context, "resolution", null, "FIXED") - .setFieldDiff(context, "status", "OPEN", "RESOLVED") + .setFieldChange(context, "resolution", null, "FIXED") + .setFieldChange(context, "status", "OPEN", "RESOLVED") .setComponentKey("struts:Action") .setProjectKey("struts"); DefaultIssueQueryResult queryResult = new DefaultIssueQueryResult(Arrays.<Issue>asList(issue)); 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 6a87cdc8674..ade4e76cbd2 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 @@ -39,7 +39,7 @@ public class IssueUpdaterTest { boolean updated = updater.assign(issue, "emmerik", context); assertThat(updated).isTrue(); assertThat(issue.assignee()).isEqualTo("emmerik"); - FieldDiffs.Diff diff = issue.diffs().get("assignee"); + FieldDiffs.Diff diff = issue.currentChange().get("assignee"); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("emmerik"); } @@ -50,7 +50,7 @@ public class IssueUpdaterTest { boolean updated = updater.assign(issue, null, context); assertThat(updated).isTrue(); assertThat(issue.assignee()).isNull(); - FieldDiffs.Diff diff = issue.diffs().get("assignee"); + FieldDiffs.Diff diff = issue.currentChange().get("assignee"); assertThat(diff.oldValue()).isEqualTo("morgan"); assertThat(diff.newValue()).isNull(); } @@ -61,7 +61,7 @@ public class IssueUpdaterTest { boolean updated = updater.assign(issue, "emmerik", context); assertThat(updated).isTrue(); assertThat(issue.assignee()).isEqualTo("emmerik"); - FieldDiffs.Diff diff = issue.diffs().get("assignee"); + FieldDiffs.Diff diff = issue.currentChange().get("assignee"); assertThat(diff.oldValue()).isEqualTo("morgan"); assertThat(diff.newValue()).isEqualTo("emmerik"); } @@ -71,7 +71,7 @@ public class IssueUpdaterTest { issue.setAssignee("morgan"); boolean updated = updater.assign(issue, "morgan", context); assertThat(updated).isFalse(); - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @@ -82,7 +82,7 @@ public class IssueUpdaterTest { assertThat(issue.severity()).isEqualTo("BLOCKER"); assertThat(issue.manualSeverity()).isFalse(); - FieldDiffs.Diff diff = issue.diffs().get("severity"); + FieldDiffs.Diff diff = issue.currentChange().get("severity"); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("BLOCKER"); } @@ -94,7 +94,7 @@ public class IssueUpdaterTest { assertThat(updated).isTrue(); assertThat(issue.severity()).isEqualTo("BLOCKER"); - FieldDiffs.Diff diff = issue.diffs().get("severity"); + FieldDiffs.Diff diff = issue.currentChange().get("severity"); assertThat(diff.oldValue()).isEqualTo("INFO"); assertThat(diff.newValue()).isEqualTo("BLOCKER"); } @@ -106,7 +106,7 @@ public class IssueUpdaterTest { assertThat(updated).isTrue(); assertThat(issue.severity()).isEqualTo("MINOR"); - FieldDiffs.Diff diff = issue.diffs().get("severity"); + FieldDiffs.Diff diff = issue.currentChange().get("severity"); assertThat(diff.oldValue()).isEqualTo("BLOCKER"); assertThat(diff.newValue()).isEqualTo("MINOR"); } @@ -116,7 +116,7 @@ public class IssueUpdaterTest { issue.setSeverity("MINOR"); boolean updated = updater.setSeverity(issue, "MINOR", context); assertThat(updated).isFalse(); - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -137,7 +137,7 @@ public class IssueUpdaterTest { assertThat(updated).isTrue(); assertThat(issue.severity()).isEqualTo("MINOR"); assertThat(issue.manualSeverity()).isTrue(); - FieldDiffs.Diff diff = issue.diffs().get("severity"); + FieldDiffs.Diff diff = issue.currentChange().get("severity"); assertThat(diff.oldValue()).isEqualTo("BLOCKER"); assertThat(diff.newValue()).isEqualTo("MINOR"); } @@ -147,7 +147,7 @@ public class IssueUpdaterTest { issue.setSeverity("MINOR").setManualSeverity(true); boolean updated = updater.setManualSeverity(issue, "MINOR", context); assertThat(updated).isFalse(); - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -157,7 +157,7 @@ public class IssueUpdaterTest { assertThat(issue.line()).isEqualTo(123); // do not save change - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -168,7 +168,7 @@ public class IssueUpdaterTest { assertThat(issue.line()).isEqualTo(42); // do not save change - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -177,7 +177,7 @@ public class IssueUpdaterTest { boolean updated = updater.setLine(issue, 123); assertThat(updated).isFalse(); assertThat(issue.line()).isEqualTo(123); - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -186,7 +186,7 @@ public class IssueUpdaterTest { assertThat(updated).isTrue(); assertThat(issue.resolution()).isEqualTo("OPEN"); - FieldDiffs.Diff diff = issue.diffs().get("resolution"); + FieldDiffs.Diff diff = issue.currentChange().get("resolution"); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("OPEN"); } @@ -197,7 +197,7 @@ public class IssueUpdaterTest { boolean updated = updater.setResolution(issue, "FIXED", context); assertThat(updated).isFalse(); assertThat(issue.resolution()).isEqualTo("FIXED"); - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -206,7 +206,7 @@ public class IssueUpdaterTest { assertThat(updated).isTrue(); assertThat(issue.status()).isEqualTo("OPEN"); - FieldDiffs.Diff diff = issue.diffs().get("status"); + FieldDiffs.Diff diff = issue.currentChange().get("status"); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("OPEN"); } @@ -217,7 +217,7 @@ public class IssueUpdaterTest { boolean updated = updater.setStatus(issue, "CLOSED", context); assertThat(updated).isFalse(); assertThat(issue.status()).isEqualTo("CLOSED"); - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -225,9 +225,9 @@ public class IssueUpdaterTest { boolean updated = updater.setAttribute(issue, "JIRA", "FOO-123", context); assertThat(updated).isTrue(); assertThat(issue.attribute("JIRA")).isEqualTo("FOO-123"); - assertThat(issue.diffs().diffs()).hasSize(1); - assertThat(issue.diffs().get("JIRA").oldValue()).isNull(); - assertThat(issue.diffs().get("JIRA").newValue()).isEqualTo("FOO-123"); + assertThat(issue.currentChange().diffs()).hasSize(1); + assertThat(issue.currentChange().get("JIRA").oldValue()).isNull(); + assertThat(issue.currentChange().get("JIRA").newValue()).isEqualTo("FOO-123"); } @Test @@ -236,9 +236,9 @@ public class IssueUpdaterTest { boolean updated = updater.setAttribute(issue, "JIRA", null, context); assertThat(updated).isTrue(); assertThat(issue.attribute("JIRA")).isNull(); - assertThat(issue.diffs().diffs()).hasSize(1); - assertThat(issue.diffs().get("JIRA").oldValue()).isEqualTo("FOO-123"); - assertThat(issue.diffs().get("JIRA").newValue()).isNull(); + assertThat(issue.currentChange().diffs()).hasSize(1); + assertThat(issue.currentChange().get("JIRA").oldValue()).isEqualTo("FOO-123"); + assertThat(issue.currentChange().get("JIRA").newValue()).isNull(); } @Test @@ -254,7 +254,7 @@ public class IssueUpdaterTest { assertThat(updated).isTrue(); assertThat(issue.actionPlanKey()).isEqualTo("ABCD"); - FieldDiffs.Diff diff = issue.diffs().get("actionPlanKey"); + FieldDiffs.Diff diff = issue.currentChange().get("actionPlanKey"); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("ABCD"); } @@ -284,7 +284,7 @@ public class IssueUpdaterTest { assertThat(issue.effortToFix()).isEqualTo(3.14); // do not save change - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -303,7 +303,7 @@ public class IssueUpdaterTest { assertThat(issue.message()).isEqualTo("new message"); // do not save change - assertThat(issue.diffs()).isNull(); + assertThat(issue.currentChange()).isNull(); } @Test @@ -312,7 +312,7 @@ public class IssueUpdaterTest { assertThat(updated).isTrue(); assertThat(issue.authorLogin()).isEqualTo("eric"); - FieldDiffs.Diff diff = issue.diffs().get("author"); + FieldDiffs.Diff diff = issue.currentChange().get("author"); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("eric"); } diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java index 21a3f64bd34..9c3bf875728 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDaoTest.java @@ -23,6 +23,7 @@ import org.apache.ibatis.session.SqlSession; import org.junit.Before; import org.junit.Test; import org.sonar.api.issue.internal.DefaultIssueComment; +import org.sonar.api.issue.internal.FieldDiffs; import org.sonar.api.utils.DateUtils; import org.sonar.core.persistence.AbstractDaoTestCase; @@ -63,16 +64,28 @@ public class IssueChangeDaoTest extends AbstractDaoTestCase { } @Test - public void selectIssueChangelog() { + public void selectCommentByKey() { setupData("shared"); - List<IssueChangeDto> changes = dao.selectIssueChangelog("1000"); - assertThat(changes).hasSize(3); + DefaultIssueComment comment = dao.selectCommentByKey("FGHIJ"); + assertThat(comment).isNotNull(); + assertThat(comment.key()).isEqualTo("FGHIJ"); + assertThat(comment.key()).isEqualTo("FGHIJ"); + assertThat(comment.userLogin()).isEqualTo("arthur"); - // chronological order - assertThat(changes.get(0).getId()).isEqualTo(100); - assertThat(changes.get(1).getId()).isEqualTo(101); - assertThat(changes.get(2).getId()).isEqualTo(102); + assertThat(dao.selectCommentByKey("UNKNOWN")).isNull(); + } + + + @Test + public void selectIssueChangelog() { + setupData("shared"); + + List<FieldDiffs> changelog = dao.selectChangelogByIssue("1000"); + assertThat(changelog).hasSize(1); + assertThat(changelog.get(0).diffs()).hasSize(1); + assertThat(changelog.get(0).diffs().get("severity").newValue()).isEqualTo("BLOCKER"); + assertThat(changelog.get(0).diffs().get("severity").oldValue()).isEqualTo("MAJOR"); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java index b65d623e911..b8744185375 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java @@ -89,7 +89,7 @@ public class IssueStorageTest extends AbstractDaoTestCase { .setChecksum("FFFFF") .setAuthorLogin("simon") .setAssignee("loic") - .setFieldDiff(context, "severity", "INFO", "BLOCKER") + .setFieldChange(context, "severity", "INFO", "BLOCKER") .setReporter("emmerik") .setResolution("FIXED") .setStatus("RESOLVED") diff --git a/sonar-core/src/test/java/org/sonar/core/user/UserDaoTest.java b/sonar-core/src/test/java/org/sonar/core/user/UserDaoTest.java index 186b20eaf56..3df4e1d875e 100644 --- a/sonar-core/src/test/java/org/sonar/core/user/UserDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/user/UserDaoTest.java @@ -25,6 +25,7 @@ import org.sonar.api.user.UserQuery; import org.sonar.core.persistence.AbstractDaoTestCase; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -60,7 +61,7 @@ public class UserDaoTest extends AbstractDaoTestCase { public void selectUsersByLogins() throws Exception { setupData("selectUsersByLogins"); - List<UserDto> users = dao.selectUsersByLogins(Arrays.asList("marius", "inactive_user", "other")); + Collection<UserDto> users = dao.selectUsersByLogins(Arrays.asList("marius", "inactive_user", "other")); assertThat(users).hasSize(2); assertThat(users).onProperty("login").containsOnly("marius", "inactive_user"); } @@ -68,7 +69,7 @@ public class UserDaoTest extends AbstractDaoTestCase { @Test public void selectUsersByLogins_empty_logins() throws Exception { // no need to access db - List<UserDto> users = dao.selectUsersByLogins(Collections.<String>emptyList()); + Collection<UserDto> users = dao.selectUsersByLogins(Collections.<String>emptyList()); assertThat(users).isEmpty(); } |