From c80b7e5d0fbbc4227cfdc73667b9dc7f3c3622c0 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 6 Feb 2014 11:24:47 +0100 Subject: [PATCH] Fix quality flaws --- .../core/issue/db/IssueChangeDtoTest.java | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDtoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDtoTest.java index 408ced20c9d..1ff0b86a1ef 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDtoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueChangeDtoTest.java @@ -24,6 +24,8 @@ import org.sonar.api.issue.internal.DefaultIssueComment; import org.sonar.api.issue.internal.FieldDiffs; import org.sonar.api.utils.DateUtils; +import java.util.Date; + import static org.fest.assertions.Assertions.assertThat; public class IssueChangeDtoTest { @@ -62,14 +64,51 @@ public class IssueChangeDtoTest { @Test public void to_comment() throws Exception { - FieldDiffs diffs = new FieldDiffs(); - diffs.setDiff("severity", "INFO", "BLOCKER"); - diffs.setUserLogin("emmerik"); - diffs.setCreationDate(null); + IssueChangeDto changeDto = new IssueChangeDto() + .setKey("EFGH") + .setUserLogin("emmerik") + .setChangeData("Some text") + .setIssueKey("ABCDE") + .setCreatedAt(new Date()) + .setUpdatedAt(new Date()); + + DefaultIssueComment comment = changeDto.toComment(); + assertThat(comment.key()).isEqualTo("EFGH"); + assertThat(comment.markdownText()).isEqualTo("Some text"); + assertThat(comment.createdAt()).isNotNull(); + assertThat(comment.updatedAt()).isNotNull(); + assertThat(comment.userLogin()).isEqualTo("emmerik"); + assertThat(comment.issueKey()).isEqualTo("ABCDE"); + } - DefaultIssueComment comment = IssueChangeDto.of("ABCDE", diffs).toComment(); + @Test + public void to_field_diffs_with_issue_creation_date() throws Exception { + IssueChangeDto changeDto = new IssueChangeDto() + .setKey("EFGH") + .setUserLogin("emmerik") + .setChangeData("Some text") + .setIssueKey("ABCDE") + .setIssueChangeCreationDate(new Date()); + FieldDiffs diffs = changeDto.toFieldDiffs(); + assertThat(diffs.userLogin()).isEqualTo("emmerik"); + assertThat(diffs.issueKey()).isEqualTo("ABCDE"); + assertThat(diffs.creationDate()).isNotNull(); + } + + @Test + public void to_field_diffs_with_create_at() throws Exception { + IssueChangeDto changeDto = new IssueChangeDto() + .setKey("EFGH") + .setUserLogin("emmerik") + .setChangeData("Some text") + .setIssueKey("ABCDE") + .setCreatedAt(new Date()); + FieldDiffs diffs = changeDto.toFieldDiffs(); + assertThat(diffs.userLogin()).isEqualTo("emmerik"); + assertThat(diffs.issueKey()).isEqualTo("ABCDE"); + assertThat(diffs.creationDate()).isNotNull(); } @Test -- 2.39.5