From 8fb5771ff79502b2a60c24404ad3f778876e0e16 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 18 Aug 2017 15:25:00 +0200 Subject: [PATCH] SONAR-9616 Return branch in issues search --- .../sonar/server/issue/ws/SearchResponseFormat.java | 3 ++- .../server/issue/ws/SearchActionComponentsTest.java | 11 ++++++----- sonar-ws/src/main/protobuf/ws-issues.proto | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java index 3b6a3909b6c..7825f08c4ee 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java @@ -160,7 +160,8 @@ public class SearchResponseFormat { ComponentDto component = data.getComponentByUuid(dto.getComponentUuid()); issueBuilder.setOrganization(data.getOrganizationKey(component.getOrganizationUuid())); - issueBuilder.setComponent(component.getDbKey()); + issueBuilder.setComponent(component.getKey()); + setNullable(component.getBranch(), issueBuilder::setBranch); ComponentDto project = data.getComponentByUuid(dto.getProjectUuid()); if (project != null) { issueBuilder.setProject(project.getDbKey()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java index 167c802ccb3..f80f1e6859b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java @@ -729,10 +729,11 @@ public class SearchActionComponentsTest { .setParam(PARAM_BRANCH, branch.getBranch()) .executeProtobuf(SearchWsResponse.class); - assertThat(result.getIssuesList()).extracting(Issues.Issue::getKey) - .containsExactlyInAnyOrder(branchIssue.getKey()) - .doesNotContain(projectIssue.getKey()); - assertThat(result.getComponentsList()).extracting(Issues.Component::getKey, Issues.Component::getBranch) + assertThat(result.getIssuesList()) + .extracting(Issue::getKey, Issue::getComponent, Issue::getBranch) + .containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchFile.getBranch())); + assertThat(result.getComponentsList()) + .extracting(Issues.Component::getKey, Issues.Component::getBranch) .containsExactlyInAnyOrder( tuple(branchFile.getKey(), branchFile.getBranch()), tuple(branch.getKey(), branch.getBranch())); @@ -752,7 +753,7 @@ public class SearchActionComponentsTest { SearchWsResponse result = ws.newRequest().executeProtobuf(SearchWsResponse.class); - assertThat(result.getIssuesList()).extracting(Issues.Issue::getKey) + assertThat(result.getIssuesList()).extracting(Issue::getKey) .containsExactlyInAnyOrder(projectIssue.getKey()) .doesNotContain(branchIssue.getKey()); } diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto index a7974885424..226691f512d 100644 --- a/sonar-ws/src/main/protobuf/ws-issues.proto +++ b/sonar-ws/src/main/protobuf/ws-issues.proto @@ -60,7 +60,6 @@ message Operation { } message Issue { - optional string organization = 29; optional string key = 1; optional string rule = 2; optional sonarqube.ws.commons.Severity severity = 3; @@ -105,6 +104,9 @@ message Issue { optional string closeDate = 26; optional sonarqube.ws.commons.RuleType type = 27; + + optional string organization = 29; + optional string branch = 30; } message Transitions { -- 2.39.5