diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-10-28 11:54:49 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-10-28 11:54:49 +0100 |
commit | 61242ad3110155c3b22028349d4bd5d0578244c0 (patch) | |
tree | 6011f608477daaca842298fb22a7dbabbf0be141 /server/sonar-server | |
parent | 12952b439abedcebcd3ea2a7ecf9af31a6ef347a (diff) | |
download | sonarqube-61242ad3110155c3b22028349d4bd5d0578244c0.tar.gz sonarqube-61242ad3110155c3b22028349d4bd5d0578244c0.zip |
SONAR-5530 Add module UUID in Issues Index
Diffstat (limited to 'server/sonar-server')
6 files changed, 25 insertions, 12 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java index 6344ad33d12..f34867afd3c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java @@ -55,6 +55,10 @@ public class IssueDoc extends BaseDoc implements Issue { return getField(IssueNormalizer.IssueField.COMPONENT.field()); } + public String moduleUuid() { + return getField(IssueNormalizer.IssueField.MODULE.field()); + } + @Override public String projectKey() { throw new IllegalStateException("projectKey is not available on server side"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueNormalizer.java index 7baa5342239..ee27fa1876a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueNormalizer.java @@ -49,11 +49,15 @@ public class IssueNormalizer extends BaseNormalizer<IssueDto, String> { public static final IndexField CREATED_AT = add(IndexField.Type.DATE, "createdAt"); public static final IndexField UPDATED_AT = add(IndexField.Type.DATE, "updatedAt"); + public static final IndexField PROJECT = add(IndexField.Type.STRING, "project"); + public static final IndexField COMPONENT = add(IndexField.Type.STRING, "component"); + public static final IndexField MODULE = add(IndexField.Type.STRING, "module"); + public static final IndexField MODULE_PATH = add(IndexField.Type.UUID_PATH, "modulePath"); + public static final IndexField ACTION_PLAN = add(IndexField.Type.STRING, "actionPlan"); public static final IndexField ASSIGNEE = addSortable(IndexField.Type.STRING, "assignee"); public static final IndexField ATTRIBUTES = add(IndexField.Type.STRING, "attributes"); public static final IndexField AUTHOR_LOGIN = add(IndexField.Type.STRING, "authorLogin"); - public static final IndexField COMPONENT = add(IndexField.Type.STRING, "component"); public static final IndexField DEBT = add(IndexField.Type.NUMERIC, "debt"); public static final IndexField EFFORT = add(IndexField.Type.NUMERIC, "effort"); public static final IndexField ISSUE_CREATED_AT = addSortable(IndexField.Type.DATE, "issueCreatedAt"); @@ -61,7 +65,6 @@ public class IssueNormalizer extends BaseNormalizer<IssueDto, String> { public static final IndexField ISSUE_CLOSE_DATE = addSortable(IndexField.Type.DATE, "issueClosedAt"); public static final IndexField LINE = add(IndexField.Type.NUMERIC, "line"); public static final IndexField MESSAGE = add(IndexField.Type.STRING, "message"); - public static final IndexField PROJECT = add(IndexField.Type.STRING, "project"); public static final IndexField RESOLUTION = add(IndexField.Type.STRING, "resolution"); public static final IndexField REPORTER = add(IndexField.Type.STRING, "reporter"); public static final IndexField STATUS = addSortable(IndexField.Type.STRING, "status"); @@ -69,7 +72,6 @@ public class IssueNormalizer extends BaseNormalizer<IssueDto, String> { public static final IndexField SEVERITY_VALUE = addSortable(IndexField.Type.NUMERIC, "severityValue"); public static final IndexField LANGUAGE = add(IndexField.Type.STRING, "language"); public static final IndexField RULE_KEY = add(IndexField.Type.STRING, "ruleKey"); - public static final IndexField MODULE_PATH = add(IndexField.Type.UUID_PATH, "modulePath"); public static final Set<IndexField> ALL_FIELDS = getAllFields(); @@ -100,14 +102,16 @@ public class IssueNormalizer extends BaseNormalizer<IssueDto, String> { update.put(IssueField.UPDATED_AT.field(), dto.getUpdatedAt()); update.put(IssueField.CREATED_AT.field(), dto.getCreatedAt()); + update.put(IssueField.PROJECT.field(), dto.getProjectUuid()); + update.put(IssueField.COMPONENT.field(), dto.getComponentUuid()); + update.put(IssueField.MODULE.field(), dto.getModuleUuid()); + update.put(IssueField.MODULE_PATH.field(), dto.getModuleUuidPath()); + update.put(IssueField.ACTION_PLAN.field(), dto.getActionPlanKey()); update.put(IssueField.ATTRIBUTES.field(), dto.getIssueAttributes()); update.put(IssueField.ASSIGNEE.field(), dto.getAssignee()); update.put(IssueField.AUTHOR_LOGIN.field(), dto.getAuthorLogin()); update.put(IssueField.ISSUE_CLOSE_DATE.field(), dto.getIssueCloseDate()); - update.put(IssueField.PROJECT.field(), dto.getProjectUuid()); - update.put(IssueField.MODULE_PATH.field(), dto.getModuleUuidPath()); - update.put(IssueField.COMPONENT.field(), dto.getComponentUuid()); update.put(IssueField.ISSUE_CREATED_AT.field(), dto.getIssueCreationDate()); update.put(IssueField.ISSUE_UPDATED_AT.field(), dto.getIssueUpdateDate()); update.put(IssueField.EFFORT.field(), dto.getEffortToFix()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java index 2e90490d2d8..e89cf357a6a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java @@ -32,7 +32,7 @@ public class ComponentTesting { return new ComponentDto() .setUuid(UUID.randomUUID().toString()) .setProjectUuid(subProjectOrProject.projectUuid()) - .setModuleUuid(!subProjectOrProject.scope().equals(Scopes.PROJECT) ? subProjectOrProject.uuid() : null) + .setModuleUuid(subProjectOrProject.uuid()) .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() : subProjectOrProject.moduleUuidPath() + "." + subProjectOrProject.uuid()) .setKey("file") .setName("File") @@ -49,7 +49,7 @@ public class ComponentTesting { return new ComponentDto() .setUuid(UUID.randomUUID().toString()) .setProjectUuid(subProjectOrProject.projectUuid()) - .setModuleUuid(!subProjectOrProject.scope().equals(Scopes.PROJECT) ? subProjectOrProject.uuid() : null) + .setModuleUuid(subProjectOrProject.uuid()) .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() : subProjectOrProject.moduleUuidPath() + "." + subProjectOrProject.uuid()) .setKey("module") .setName("Module") diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java index 20206917490..ee6d3fa63e8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java @@ -170,7 +170,7 @@ public class IssueServiceMediumTest { session.commit(); assertThat(db.issueDao().getByKey(session, issue.getKey())).isNotNull(); - IssueTesting.assertIsEquivalent(issue, indexClient.get(IssueIndex.class).getByKey(issue.getKey())); + IssueTesting.assertIsEquivalent(issue, (IssueDoc) indexClient.get(IssueIndex.class).getByKey(issue.getKey())); assertThat(indexClient.get(IssueIndex.class).getByKey(issue.getKey()).status()).isEqualTo(Issue.STATUS_OPEN); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java index 081d65a694c..c3d2d41840e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java @@ -27,6 +27,7 @@ import org.sonar.api.utils.KeyValueFormat; import org.sonar.core.component.ComponentDto; import org.sonar.core.issue.db.IssueDto; import org.sonar.core.rule.RuleDto; +import org.sonar.server.issue.index.IssueDoc; import java.util.UUID; @@ -56,11 +57,15 @@ public class IssueTesting { .setIssueUpdateDate(DateUtils.parseDate("2014-12-04")); } - public static void assertIsEquivalent(IssueDto dto, Issue issue) { + public static void assertIsEquivalent(IssueDto dto, IssueDoc issue) { assertThat(issue).isNotNull(); assertThat(dto).isNotNull(); assertThat(issue.key()).isEqualTo(dto.getKey()); + assertThat(issue.componentUuid()).isEqualTo(dto.getComponentUuid()); + assertThat(issue.moduleUuid()).isEqualTo(dto.getModuleUuid()); + assertThat(issue.projectUuid()).isEqualTo(dto.getProjectUuid()); + assertThat(issue.actionPlanKey()).isEqualTo(dto.getActionPlanKey()); assertThat(issue.assignee()).isEqualTo(dto.getAssignee()); assertThat(issue.authorLogin()).isEqualTo(dto.getAuthorLogin()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexMediumTest.java index 2119cd161e4..08e4f05559d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexMediumTest.java @@ -110,7 +110,7 @@ public class IssueIndexMediumTest { session.commit(); Issue result = index.getByKey(issue.getKey()); - IssueTesting.assertIsEquivalent(issue, result); + IssueTesting.assertIsEquivalent(issue, (IssueDoc) result); } @Test @@ -120,7 +120,7 @@ public class IssueIndexMediumTest { session.commit(); Issue result = index.getByKey(issue.getKey()); - IssueTesting.assertIsEquivalent(issue, result); + IssueTesting.assertIsEquivalent(issue, (IssueDoc) result); assertThat(result.attribute("jira-issue-key")).isEqualTo("SONAR-1234"); } |