use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CancelActionTest method cancel_pending_task_when_project_administer.
@Test
public void cancel_pending_task_when_project_administer() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.ADMIN, project);
CeQueueDto queue = createTaskSubmit(project);
tester.newRequest().setParam("id", queue.getUuid()).execute();
assertThat(db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), queue.getUuid()).get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CancelActionTest method throw_ForbiddenException_if_not_enough_permission_when_canceling_task_without_project.
@Test
public void throw_ForbiddenException_if_not_enough_permission_when_canceling_task_without_project() {
userSession.logIn().setNonSystemAdministrator();
CeQueueDto queue = createTaskSubmit(null);
assertThatThrownBy(() -> {
tester.newRequest().setParam("id", queue.getUuid()).execute();
}).isInstanceOf(ForbiddenException.class).hasMessage("Insufficient privileges");
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CancelActionTest method cancel_pending_task_when_system_administer.
@Test
public void cancel_pending_task_when_system_administer() {
logInAsSystemAdministrator();
ComponentDto project = db.components().insertPrivateProject();
CeQueueDto queue = createTaskSubmit(project);
tester.newRequest().setParam("id", queue.getUuid()).execute();
assertThat(db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), queue.getUuid()).get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class ComponentActionTest method branch_in_queue_analysis.
@Test
public void branch_in_queue_analysis() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
CeQueueDto queue1 = insertQueue("T1", project, IN_PROGRESS);
insertCharacteristic(queue1, BRANCH_KEY, branch.getBranch());
insertCharacteristic(queue1, BRANCH_TYPE_KEY, BRANCH.name());
CeQueueDto queue2 = insertQueue("T2", project, PENDING);
insertCharacteristic(queue2, BRANCH_KEY, branch.getBranch());
insertCharacteristic(queue2, BRANCH_TYPE_KEY, BRANCH.name());
Ce.ComponentResponse response = ws.newRequest().setParam(PARAM_COMPONENT, branch.getKey()).executeProtobuf(Ce.ComponentResponse.class);
assertThat(response.getQueueList()).extracting(Ce.Task::getId, Ce.Task::getBranch, Ce.Task::getBranchType, Ce.Task::getStatus, Ce.Task::getComponentKey, Ce.Task::getWarningCount, Ce.Task::getWarningsList).containsOnly(tuple("T1", branch.getBranch(), Common.BranchType.BRANCH, Ce.TaskStatus.IN_PROGRESS, project.getKey(), 0, emptyList()), tuple("T2", branch.getBranch(), Common.BranchType.BRANCH, Ce.TaskStatus.PENDING, project.getKey(), 0, emptyList()));
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class ComponentActionTest method return_many_tasks_from_same_project.
@Test
public void return_many_tasks_from_same_project() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
insertQueue("Main", project, IN_PROGRESS);
ComponentDto branch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH).setKey("branch1"));
CeQueueDto branchQueue1 = insertQueue("Branch1", project, IN_PROGRESS);
insertCharacteristic(branchQueue1, BRANCH_KEY, branch1.getBranch());
insertCharacteristic(branchQueue1, BRANCH_TYPE_KEY, BRANCH.name());
ComponentDto branch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH).setKey("branch2"));
CeQueueDto branchQueue2 = insertQueue("Branch2", project, PENDING);
insertCharacteristic(branchQueue2, BRANCH_KEY, branch2.getBranch());
insertCharacteristic(branchQueue2, BRANCH_TYPE_KEY, BRANCH.name());
Ce.ComponentResponse response = ws.newRequest().setParam(PARAM_COMPONENT, branch1.getKey()).executeProtobuf(Ce.ComponentResponse.class);
assertThat(response.getQueueList()).extracting(Ce.Task::getId, Ce.Task::getComponentKey, Ce.Task::getBranch, Ce.Task::getBranchType, Ce.Task::getWarningCount, Ce.Task::getWarningsList).containsOnly(tuple("Main", project.getKey(), "", Common.BranchType.UNKNOWN_BRANCH_TYPE, 0, emptyList()), tuple("Branch1", branch1.getKey(), branch1.getBranch(), Common.BranchType.BRANCH, 0, emptyList()), tuple("Branch2", branch2.getKey(), branch2.getBranch(), Common.BranchType.BRANCH, 0, emptyList()));
}
Aggregations