diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-12-14 18:56:53 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-12-15 14:45:04 +0100 |
commit | 6e6f004f24142e3739c892bbee9153c26a51d0a1 (patch) | |
tree | b62be7b9d99be931fdf3cb996c63d8b5ea5dc0ab /sonar-db | |
parent | f708dfbad7bacac33b18bb5c7c1221565b803fa5 (diff) | |
download | sonarqube-6e6f004f24142e3739c892bbee9153c26a51d0a1.tar.gz sonarqube-6e6f004f24142e3739c892bbee9153c26a51d0a1.zip |
SONAR-7294 Replace Ruby WS api/issues/edit_comment
Diffstat (limited to 'sonar-db')
3 files changed, 7 insertions, 15 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java index 95e33f0c7bd..ff7fcaa53fa 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java @@ -106,17 +106,9 @@ public class IssueChangeDao implements Dao { } } - public boolean update(IssueChangeDto change) { - DbSession session = mybatis.openSession(false); - try { - IssueChangeMapper mapper = mapper(session); - int count = mapper.update(change); - session.commit(); - return count == 1; - - } finally { - MyBatis.closeQuietly(session); - } + public boolean update(DbSession dbSession, IssueChangeDto change) { + int count = mapper(dbSession).update(change); + return count == 1; } private static IssueChangeMapper mapper(DbSession session) { diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDto.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDto.java index a1150b078c3..7ff18e9afd4 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDto.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDto.java @@ -110,6 +110,7 @@ public final class IssueChangeDto implements Serializable { return this; } + @CheckForNull public String getUserLogin() { return userLogin; } diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java index a1c2397efc6..7f9349356d6 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java @@ -178,7 +178,8 @@ public class IssueChangeDaoTest { change.setChangeData("new comment"); change.setUpdatedAt(1_500_000_000_000L); - assertThat(underTest.update(change)).isTrue(); + assertThat(underTest.update(db.getSession(), change)).isTrue(); + db.commit(); db.assertDbUnit(getClass(), "update-result.xml", "issue_changes"); } @@ -189,12 +190,10 @@ public class IssueChangeDaoTest { IssueChangeDto change = new IssueChangeDto(); change.setKey("UNKNOWN"); - - // Only the following fields can be updated: change.setChangeData("new comment"); change.setUpdatedAt(DateUtils.parseDate("2013-06-30").getTime()); - assertThat(underTest.update(change)).isFalse(); + assertThat(underTest.update(db.getSession(), change)).isFalse(); } } |