use of org.sonarqube.ws.ProjectBranches.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method main_branch.
@Test
public void main_branch() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(USER, project);
ListWsResponse response = ws.newRequest().setParam("project", project.getDbKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getBranchesList()).extracting(Branch::getName, Branch::getIsMain, Branch::getType).containsExactlyInAnyOrder(tuple("master", true, BranchType.BRANCH));
}
use of org.sonarqube.ws.ProjectBranches.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method status_on_branch.
@Test
public void status_on_branch() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.BRANCH));
db.measures().insertLiveMeasure(branch, qualityGateStatus, m -> m.setData("OK"));
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getBranchesList()).extracting(b -> b.getStatus().hasQualityGateStatus(), b -> b.getStatus().getQualityGateStatus()).containsExactlyInAnyOrder(tuple(false, ""), tuple(true, "OK"));
}
use of org.sonarqube.ws.ProjectBranches.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method main_branch_with_specified_name.
@Test
public void main_branch_with_specified_name() {
ComponentDto project = db.components().insertPrivateProject();
db.getDbClient().branchDao().updateMainBranchName(db.getSession(), project.uuid(), "head");
db.commit();
userSession.logIn().addProjectPermission(USER, project);
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getBranchesList()).extracting(Branch::getName, Branch::getIsMain, Branch::getType).containsExactlyInAnyOrder(tuple("head", true, BranchType.BRANCH));
}
use of org.sonarqube.ws.ProjectBranches.ListWsResponse in project sonarqube by SonarSource.
the class ListActionTest method application_branches.
@Test
public void application_branches() {
ComponentDto application = db.components().insertPrivateApplication();
db.components().insertProjectBranch(application, b -> b.setKey("feature/bar"));
db.components().insertProjectBranch(application, b -> b.setKey("feature/foo"));
userSession.logIn().addProjectPermission(USER, application);
ListWsResponse response = ws.newRequest().setParam("project", application.getDbKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getBranchesList()).extracting(Branch::getName, Branch::getType).containsExactlyInAnyOrder(tuple("master", BranchType.BRANCH), tuple("feature/foo", BranchType.BRANCH), tuple("feature/bar", BranchType.BRANCH));
}
use of org.sonarqube.ws.ProjectBranches.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 lastAnalysisBranch = dateToLong(parseDateTime("2017-04-01T00:00:00+0100"));
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().addProjectPermission(USER, project);
ComponentDto branch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.BRANCH));
db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(branch2).setCreatedAt(lastAnalysisBranch));
db.commit();
indexIssues();
permissionIndexerTester.allowOnlyAnyone(project);
ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
assertThat(response.getBranchesList()).extracting(ProjectBranches.Branch::getType, ProjectBranches.Branch::hasAnalysisDate, b -> "".equals(b.getAnalysisDate()) ? null : dateToLong(parseDateTime(b.getAnalysisDate()))).containsExactlyInAnyOrder(tuple(BranchType.BRANCH, false, null), tuple(BranchType.BRANCH, true, lastAnalysisBranch));
}
Aggregations