aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-08-18 15:25:00 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-09-12 11:34:47 +0200
commit8fb5771ff79502b2a60c24404ad3f778876e0e16 (patch)
treef534c417c3246d517a56fd728ddbf23e38086e2d
parent0b11b278fde4daaf3c928a24a2aa3bab21a9982c (diff)
downloadsonarqube-8fb5771ff79502b2a60c24404ad3f778876e0e16.tar.gz
sonarqube-8fb5771ff79502b2a60c24404ad3f778876e0e16.zip
SONAR-9616 Return branch in 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.java11
-rw-r--r--sonar-ws/src/main/protobuf/ws-issues.proto4
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 {