Search in sources :

Example 86 with CeQueueDto

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);
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 87 with CeQueueDto

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");
}
Also used : ForbiddenException(org.sonar.server.exceptions.ForbiddenException) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 88 with CeQueueDto

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);
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 89 with CeQueueDto

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()));
}
Also used : Ce(org.sonarqube.ws.Ce) ComponentDto(org.sonar.db.component.ComponentDto) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 90 with CeQueueDto

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()));
}
Also used : Ce(org.sonarqube.ws.Ce) ComponentDto(org.sonar.db.component.ComponentDto) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Aggregations

CeQueueDto (org.sonar.db.ce.CeQueueDto)120 Test (org.junit.Test)58 CeActivityDto (org.sonar.db.ce.CeActivityDto)36 ComponentDto (org.sonar.db.component.ComponentDto)20 DbSession (org.sonar.db.DbSession)18 CeTask (org.sonar.ce.task.CeTask)17 UserDto (org.sonar.db.user.UserDto)17 Ce (org.sonarqube.ws.Ce)11 CeTaskCharacteristicDto (org.sonar.db.ce.CeTaskCharacteristicDto)6 List (java.util.List)5 Optional (java.util.Optional)5 Random (java.util.Random)5 Collectors (java.util.stream.Collectors)5 System2 (org.sonar.api.utils.System2)5 Arrays (java.util.Arrays)4 Arrays.asList (java.util.Arrays.asList)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Date (java.util.Date)4 IntStream (java.util.stream.IntStream)4