From 09a2697f50fd4cf2895c7d62957fcb1f4852fe52 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 11 Aug 2017 07:42:04 +0200 Subject: SONAR-9616 Return component branch in api/issues/search --- .../src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java | 3 ++- .../java/org/sonar/server/issue/ws/SearchActionComponentsTest.java | 4 ++++ sonar-ws/src/main/protobuf/ws-issues.proto | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) 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 ac05cc4e498..3b6a3909b6c 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 @@ -300,12 +300,13 @@ public class SearchResponseFormat { String uuid = dto.uuid(); Component.Builder builder = Component.newBuilder() .setOrganization(data.getOrganizationKey(dto.getOrganizationUuid())) - .setKey(dto.getDbKey()) + .setKey(dto.getKey()) .setUuid(uuid) .setQualifier(dto.qualifier()) .setName(nullToEmpty(dto.name())) .setLongName(nullToEmpty(dto.longName())) .setEnabled(dto.isEnabled()); + setNullable(dto.getBranch(), builder::setBranch); String path = dto.path(); // path is not applicable to the components that are not files. // Value must not be "" in this case. 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 1199319529a..167c802ccb3 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 @@ -732,6 +732,10 @@ public class SearchActionComponentsTest { assertThat(result.getIssuesList()).extracting(Issues.Issue::getKey) .containsExactlyInAnyOrder(branchIssue.getKey()) .doesNotContain(projectIssue.getKey()); + assertThat(result.getComponentsList()).extracting(Issues.Component::getKey, Issues.Component::getBranch) + .containsExactlyInAnyOrder( + tuple(branchFile.getKey(), branchFile.getBranch()), + tuple(branch.getKey(), branch.getBranch())); } @Test diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto index ce03b0180d7..a7974885424 100644 --- a/sonar-ws/src/main/protobuf/ws-issues.proto +++ b/sonar-ws/src/main/protobuf/ws-issues.proto @@ -182,6 +182,7 @@ message Component { optional string path = 8; optional int64 unusedProjectId = 9; optional int64 unusedSubProjectId = 10; + optional string branch = 12; } // Response of GET api/issues/changelog -- cgit v1.2.3