aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-08-11 07:42:04 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-09-12 10:59:55 +0200
commit09a2697f50fd4cf2895c7d62957fcb1f4852fe52 (patch)
treeb32e612d7949541150da6c7259edc7e6c3f44557
parent51d27511afe2e90b3843d3f1248a54f06215129b (diff)
downloadsonarqube-09a2697f50fd4cf2895c7d62957fcb1f4852fe52.tar.gz
sonarqube-09a2697f50fd4cf2895c7d62957fcb1f4852fe52.zip
SONAR-9616 Return component branch in api/issues/search
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java4
-rw-r--r--sonar-ws/src/main/protobuf/ws-issues.proto1
3 files changed, 7 insertions, 1 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 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