Skip to content

Commit

Permalink
SONAR-10570 Do not return an empty pull request URL when it's not pro…
Browse files Browse the repository at this point in the history
…vided
  • Loading branch information
teryk authored and SonarTech committed Apr 27, 2018
1 parent 358970f commit 64a7ab5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.sonarqube.ws.ProjectPullRequests;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.emptyToNull;
import static java.util.Collections.singletonList;
import static java.util.Objects.requireNonNull;
import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY;
Expand Down Expand Up @@ -140,8 +141,8 @@ private static void addPullRequest(ProjectPullRequests.ListWsResponse.Builder re

DbProjectBranches.PullRequestData pullRequestData = requireNonNull(branch.getPullRequestData(), "Pull request data should be available for branch type PULL_REQUEST");
builder.setBranch(pullRequestData.getBranch());
builder.setUrl(pullRequestData.getUrl());
builder.setTitle(pullRequestData.getTitle());
setNullable(emptyToNull(pullRequestData.getUrl()), builder::setUrl);
setNullable(emptyToNull(pullRequestData.getTitle()), builder::setTitle);

if (mergeBranch.isPresent()) {
String mergeBranchKey = mergeBranch.get().getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public void pull_request() {
.executeProtobuf(ListWsResponse.class);

assertThat(response.getPullRequestsList())
.extracting(PullRequest::getKey, PullRequest::getBranch, PullRequest::getIsOrphan)
.containsExactlyInAnyOrder(tuple("123", "feature/bar", false));
.extracting(PullRequest::getKey, PullRequest::getBranch, PullRequest::getIsOrphan, PullRequest::hasUrl, PullRequest::hasTitle)
.containsExactlyInAnyOrder(tuple("123", "feature/bar", false, false, false));
}

@Test
Expand Down

0 comments on commit 64a7ab5

Please sign in to comment.