]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9616 Return branch in issues search
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 18 Aug 2017 13:25:00 +0000 (15:25 +0200)
committerJanos Gyerik <janos.gyerik@sonarsource.com>
Tue, 12 Sep 2017 09:34:47 +0000 (11:34 +0200)
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
sonar-ws/src/main/protobuf/ws-issues.proto

index 3b6a3909b6ce1ef653310efd0fa50ae1315cdaea..7825f08c4ee9ec9629691e9b857e22e33a83481b 100644 (file)
@@ -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());
index 167c802ccb3fc0de71f0319ef41471f3de03c117..f80f1e6859b89bbd5a48fdf791416ab45be6accc 100644 (file)
@@ -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());
   }
index a797488542409b68c596b17762dec5b46cb3c82f..226691f512d9153fac87d43ce5c8ab4c6c98597f 100644 (file)
@@ -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 {