use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method base_branch_is_using_default_main_name_when_main_branch_has_no_name.
@Test
public void base_branch_is_using_default_main_name_when_main_branch_has_no_name() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST).setMergeBranchUuid(project.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature123").build()));
ListWsResponse response = ws.newRequest().setParam("project", pullRequest.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequests(0)).extracting(PullRequest::getKey, PullRequest::getBase).containsExactlyInAnyOrder(pullRequest.getPullRequest(), "master");
}
use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method response_contains_date_of_last_analysis.
@Test
public void response_contains_date_of_last_analysis() {
Long lastAnalysisNonMainBranch = dateToLong(parseDateTime("2017-04-01T00:00:00+0100"));
Long previousAnalysisPullRequest = dateToLong(parseDateTime("2017-04-02T00:00:00+0100"));
Long lastAnalysisPullRequest = dateToLong(parseDateTime("2017-04-03T00:00:00+0100"));
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto pullRequest1 = db.components().insertProjectBranch(project, b -> b.setKey("pr1").setBranchType(PULL_REQUEST).setMergeBranchUuid(project.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/pr1").build()));
ComponentDto nonMainBranch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
ComponentDto pullRequest2 = db.components().insertProjectBranch(project, b -> b.setKey("pr2").setBranchType(PULL_REQUEST).setMergeBranchUuid(nonMainBranch2.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/pr2").build()));
db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(nonMainBranch2).setCreatedAt(lastAnalysisNonMainBranch));
db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(pullRequest2).setCreatedAt(previousAnalysisPullRequest).setLast(false));
db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(pullRequest2).setCreatedAt(lastAnalysisPullRequest));
db.commit();
indexIssues();
permissionIndexerTester.allowOnlyAnyone(project);
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequestsList()).extracting(PullRequest::hasAnalysisDate, b -> "".equals(b.getAnalysisDate()) ? null : dateToLong(parseDateTime(b.getAnalysisDate()))).containsExactlyInAnyOrder(tuple(false, null), tuple(true, lastAnalysisPullRequest));
}
use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method pull_request_on_removed_branch.
@Test
public void pull_request_on_removed_branch() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST).setMergeBranchUuid("unknown").setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/bar").build()));
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequestsList()).extracting(PullRequest::getKey, PullRequest::hasBase, PullRequest::getIsOrphan).containsExactlyInAnyOrder(tuple(pullRequest.getPullRequest(), false, true));
}
use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method does_not_fail_when_only_scan_permission_on_project.
@Test
public void does_not_fail_when_only_scan_permission_on_project() {
ComponentDto project = db.components().insertPublicProject();
db.components().insertProjectBranch(project, b -> b.setKey("123").setBranchType(PULL_REQUEST).setMergeBranchUuid(project.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/bar").build()));
userSession.logIn().addProjectPermission(SCAN_EXECUTION, project);
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequestsList()).extracting(PullRequest::getKey).containsExactlyInAnyOrder("123");
}
use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method does_not_fail_when_only_scan_permission.
@Test
public void does_not_fail_when_only_scan_permission() {
userSession.logIn().addPermission(GlobalPermission.SCAN);
ComponentDto project = db.components().insertPublicProject();
db.components().insertProjectBranch(project, b -> b.setKey("123").setBranchType(PULL_REQUEST).setMergeBranchUuid(project.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/bar").build()));
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequestsList()).extracting(PullRequest::getKey).containsExactlyInAnyOrder("123");
}
Aggregations