use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method pull_requests.
@Test
public void pull_requests() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto nonMainBranch = db.components().insertProjectBranch(project, b -> b.setKey("branch1").setBranchType(BranchType.BRANCH));
ComponentDto pullRequestOnNonMainBranch = db.components().insertProjectBranch(project, b -> b.setKey("pull_request_on_branch1").setBranchType(PULL_REQUEST).setMergeBranchUuid(nonMainBranch.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/bar").build()));
ComponentDto pullRequestOnMaster = db.components().insertProjectBranch(project, b -> b.setKey("pull_request_on_master").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, PullRequest::getBase).containsExactlyInAnyOrder(tuple(pullRequestOnNonMainBranch.getPullRequest(), nonMainBranch.getBranch()), tuple(pullRequestOnMaster.getPullRequest(), "master"));
}
use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method status_on_pull_requests.
@Test
public void status_on_pull_requests() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto nonMainBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST).setMergeBranchUuid(nonMainBranch.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/bar").build()));
db.measures().insertLiveMeasure(pullRequest, qualityGateStatus, m -> m.setData("ERROR"));
RuleDefinitionDto rule = db.rules().insert();
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(BUG).setResolution(null));
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(BUG).setResolution(RESOLUTION_FIXED));
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(VULNERABILITY).setResolution(null));
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(VULNERABILITY).setResolution(null));
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(CODE_SMELL).setResolution(null));
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(CODE_SMELL).setResolution(null));
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(CODE_SMELL).setResolution(null));
db.issues().insert(rule, pullRequest, pullRequest, i -> i.setType(CODE_SMELL).setResolution(RESOLUTION_FALSE_POSITIVE));
indexIssues();
permissionIndexerTester.allowOnlyAnyone(project);
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequestsList().stream().map(PullRequest::getStatus)).extracting(Status::getQualityGateStatus, Status::hasBugs, Status::getBugs, Status::hasVulnerabilities, Status::getVulnerabilities, Status::hasCodeSmells, Status::getCodeSmells).containsExactlyInAnyOrder(tuple("ERROR", true, 1L, true, 2L, true, 3L));
}
use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method pull_request.
@Test
public void pull_request() {
ComponentDto project = db.components().insertPrivateProject();
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(UserRole.USER, project);
ListWsResponse response = ws.newRequest().setParam("project", project.getDbKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequestsList()).extracting(PullRequest::getKey, PullRequest::getBranch, PullRequest::getIsOrphan, PullRequest::hasUrl, PullRequest::hasTitle).containsExactlyInAnyOrder(tuple("123", "feature/bar", false, false, false));
}
use of org.sonarqube.ws.ProjectPullRequests.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method does_not_fail_when_only_browse_permission_on_project.
@Test
public void does_not_fail_when_only_browse_permission_on_project() {
ComponentDto project = db.components().insertPrivateProject();
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(UserRole.USER, 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 status_on_pull_request_with_no_issue.
@Test
public void status_on_pull_request_with_no_issue() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto nonMainBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST).setMergeBranchUuid(nonMainBranch.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/bar").build()));
indexIssues();
permissionIndexerTester.allowOnlyAnyone(project);
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getPullRequestsList().stream().map(PullRequest::getStatus)).extracting(Status::getBugs, Status::getVulnerabilities, Status::getCodeSmells).containsExactlyInAnyOrder(tuple(0L, 0L, 0L));
}
Aggregations