Search in sources :

Example 26 with CeActivityDto

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

the class TaskActionTest method getting_project_archived_task_throws_ForbiddenException_if_no_admin_nor_scan_permissions.

@Test
public void getting_project_archived_task_throws_ForbiddenException_if_no_admin_nor_scan_permissions() {
    userSession.logIn();
    CeActivityDto task = createAndPersistArchivedTask(project);
    expectedException.expect(ForbiddenException.class);
    call(task.getUuid());
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) Test(org.junit.Test)

Example 27 with CeActivityDto

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

the class TaskActionTest method get_project_archived_task_with_scan_permission_on_organization_but_not_on_project.

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

Example 28 with CeActivityDto

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

the class TaskActionTest method do_not_return_stacktrace_of_failed_activity_without_stacktrace.

@Test
public void do_not_return_stacktrace_of_failed_activity_without_stacktrace() {
    logInAsRoot();
    CeActivityDto activityDto = createActivityDto(SOME_TASK_UUID).setErrorMessage("error msg");
    persist(activityDto);
    TestResponse wsResponse = ws.newRequest().setMediaType(PROTOBUF).setParam("id", SOME_TASK_UUID).execute();
    WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
    WsCe.Task task = taskResponse.getTask();
    assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
    assertThat(task.getErrorMessage()).isEqualTo(activityDto.getErrorMessage());
    assertThat(task.hasErrorStacktrace()).isFalse();
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) TestResponse(org.sonar.server.ws.TestResponse) WsCe(org.sonarqube.ws.WsCe) Test(org.junit.Test)

Example 29 with CeActivityDto

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

the class TaskFormatterTest method formatActivity_set_scanner_context_if_argument_is_non_null.

@Test
public void formatActivity_set_scanner_context_if_argument_is_non_null() {
    CeActivityDto dto = newActivity("UUID", "COMPONENT_UUID", CeActivityDto.Status.FAILED);
    String expected = "scanner context baby!";
    WsCe.Task wsTask = underTest.formatActivity(db.getSession(), dto, Optional.absent(), expected);
    assertThat(wsTask.hasScannerContext()).isTrue();
    assertThat(wsTask.getScannerContext()).isEqualTo(expected);
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) WsCe(org.sonarqube.ws.WsCe) Test(org.junit.Test)

Example 30 with CeActivityDto

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

the class TaskFormatterTest method formatActivity_with_both_error_message_only.

@Test
public void formatActivity_with_both_error_message_only() {
    CeActivityDto dto = newActivity("UUID", "COMPONENT_UUID", CeActivityDto.Status.FAILED).setErrorMessage("error msg");
    WsCe.Task task = underTest.formatActivity(db.getSession(), Collections.singletonList(dto)).iterator().next();
    assertThat(task.getErrorMessage()).isEqualTo(dto.getErrorMessage());
    assertThat(task.hasErrorStacktrace()).isFalse();
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) WsCe(org.sonarqube.ws.WsCe) Test(org.junit.Test)

Aggregations

CeActivityDto (org.sonar.db.ce.CeActivityDto)33 Test (org.junit.Test)21 CeQueueDto (org.sonar.db.ce.CeQueueDto)11 WsCe (org.sonarqube.ws.WsCe)9 CeTask (org.sonar.ce.queue.CeTask)6 TestResponse (org.sonar.server.ws.TestResponse)4 DbSession (org.sonar.db.DbSession)3 ComponentDto (org.sonar.db.component.ComponentDto)2 Date (java.util.Date)1 StringUtils.defaultString (org.apache.commons.lang.StringUtils.defaultString)1 Status (org.sonar.db.ce.CeQueueDto.Status)1 CeTaskQuery (org.sonar.db.ce.CeTaskQuery)1 ProjectResponse (org.sonarqube.ws.WsCe.ProjectResponse)1