Search in sources :

Example 11 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class TaskActionTest method get_project_queue_task_with_scan_permission_on_organization_but_not_on_project.

@Test
public void get_project_queue_task_with_scan_permission_on_organization_but_not_on_project() {
    userSession.logIn().addPermission(SCAN, project.getOrganizationUuid());
    CeQueueDto task = createAndPersistQueueTask(project);
    call(task.getUuid());
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 12 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class TaskActionTest method task_is_in_queue.

@Test
public void task_is_in_queue() throws Exception {
    logInAsRoot();
    CeQueueDto queueDto = new CeQueueDto();
    queueDto.setTaskType(CeTaskTypes.REPORT);
    queueDto.setUuid(SOME_TASK_UUID);
    queueDto.setComponentUuid(project.uuid());
    queueDto.setStatus(CeQueueDto.Status.PENDING);
    queueDto.setSubmitterLogin("john");
    persist(queueDto);
    TestResponse wsResponse = ws.newRequest().setMediaType(PROTOBUF).setParam("id", SOME_TASK_UUID).execute();
    WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
    assertThat(taskResponse.getTask().getOrganization()).isEqualTo(organizationDto.getKey());
    assertThat(taskResponse.getTask().getId()).isEqualTo(SOME_TASK_UUID);
    assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
    assertThat(taskResponse.getTask().getSubmitterLogin()).isEqualTo("john");
    assertThat(taskResponse.getTask().getComponentId()).isEqualTo(project.uuid());
    assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.key());
    assertThat(taskResponse.getTask().getComponentName()).isEqualTo(project.name());
    assertThat(taskResponse.getTask().hasExecutionTimeMs()).isFalse();
    assertThat(taskResponse.getTask().getLogs()).isFalse();
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) WsCe(org.sonarqube.ws.WsCe) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 13 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class ActivityActionTest method insertActivity.

private CeActivityDto insertActivity(String taskUuid, String componentUuid, CeActivityDto.Status status) {
    CeQueueDto queueDto = new CeQueueDto();
    queueDto.setTaskType(CeTaskTypes.REPORT);
    queueDto.setComponentUuid(componentUuid);
    queueDto.setUuid(taskUuid);
    queueDto.setCreatedAt(EXECUTED_AT);
    CeActivityDto activityDto = new CeActivityDto(queueDto);
    activityDto.setStatus(status);
    activityDto.setExecutionTimeMs(500L);
    activityDto.setExecutedAt(EXECUTED_AT);
    activityDto.setAnalysisUuid("U1");
    dbTester.getDbClient().ceActivityDao().insert(dbTester.getSession(), activityDto);
    dbTester.commit();
    return activityDto;
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 14 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class TaskActionTest method getting_global_queue_throws_ForbiddenException_if_not_system_administrator.

@Test
public void getting_global_queue_throws_ForbiddenException_if_not_system_administrator() {
    userSession.logIn().setNonSystemAdministrator();
    CeQueueDto task = createAndPersistQueueTask(null);
    expectedException.expect(ForbiddenException.class);
    call(task.getUuid());
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 15 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class TaskActionTest method createAndPersistArchivedTask.

private CeActivityDto createAndPersistArchivedTask(@Nullable ComponentDto component) {
    CeQueueDto queueDto = new CeQueueDto();
    queueDto.setTaskType(CeTaskTypes.REPORT);
    queueDto.setUuid(SOME_TASK_UUID);
    if (component != null) {
        queueDto.setComponentUuid(component.uuid());
    }
    CeActivityDto activityDto = new CeActivityDto(queueDto);
    activityDto.setStatus(CeActivityDto.Status.FAILED);
    activityDto.setExecutionTimeMs(500L);
    activityDto.setAnalysisUuid(SOME_TASK_UUID + "_u1");
    persist(activityDto);
    return activityDto;
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Aggregations

CeQueueDto (org.sonar.db.ce.CeQueueDto)32 Test (org.junit.Test)11 CeActivityDto (org.sonar.db.ce.CeActivityDto)11 DbSession (org.sonar.db.DbSession)8 WsCe (org.sonarqube.ws.WsCe)5 ComponentDto (org.sonar.db.component.ComponentDto)2 Date (java.util.Date)1 StringUtils.defaultString (org.apache.commons.lang.StringUtils.defaultString)1 CeTask (org.sonar.ce.queue.CeTask)1 Status (org.sonar.db.ce.CeQueueDto.Status)1 CeTaskQuery (org.sonar.db.ce.CeTaskQuery)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 TestResponse (org.sonar.server.ws.TestResponse)1 ProjectResponse (org.sonarqube.ws.WsCe.ProjectResponse)1