diff options
author | Belen Pruvost <belen.pruvost@sonarsource.com> | 2022-03-29 10:40:53 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-31 20:02:59 +0000 |
commit | 5db8293aeefbd683b9288bbc5d0dee5d9e407546 (patch) | |
tree | 594fbd37e54080f17fbef1d5740cba2192e89f87 /server/sonar-db-dao | |
parent | b7df67a2d8bed8bd01baf11368b26ac417a2868b (diff) | |
download | sonarqube-5db8293aeefbd683b9288bbc5d0dee5d9e407546.tar.gz sonarqube-5db8293aeefbd683b9288bbc5d0dee5d9e407546.zip |
SONAR-16039 - Migrate existing issues to new_code table
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(); + } } |