diff options
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r-- | server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java | 7 | ||||
-rw-r--r-- | server/sonar-db-dao/src/test/java/org/sonar/db/issue/NewCodeReferenceIssueDtoTest.java | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java index 1ca29e296e6..719a12e7986 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java @@ -66,4 +66,11 @@ public final class NewCodeReferenceIssueDto implements Serializable { .setIssueKey(issue.getKey()) .setCreatedAt(now); } + + public static NewCodeReferenceIssueDto fromIssueKey(String issueKey, long now, UuidFactory uuidFactory) { + return new NewCodeReferenceIssueDto() + .setUuid(uuidFactory.create()) + .setIssueKey(issueKey) + .setCreatedAt(now); + } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/NewCodeReferenceIssueDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/NewCodeReferenceIssueDtoTest.java index 2bcbd5d0189..ffa7d5dae27 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/NewCodeReferenceIssueDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/NewCodeReferenceIssueDtoTest.java @@ -45,4 +45,16 @@ public class NewCodeReferenceIssueDtoTest { assertThat(dto.getIssueKey()).isEqualTo(KEY); assertThat(dto.getCreatedAt()).isNotNull(); } + + @Test + public void create_from_issue_key() { + when(UUID_FACTORY.create()).thenReturn(UUID); + long now = System.currentTimeMillis(); + + NewCodeReferenceIssueDto dto = NewCodeReferenceIssueDto.fromIssueKey(KEY, now, UUID_FACTORY); + + assertThat(dto.getUuid()).isEqualTo(UUID); + assertThat(dto.getIssueKey()).isEqualTo(KEY); + assertThat(dto.getCreatedAt()).isNotNull(); + } } |