Search in sources :

Example 6 with ActivityResponse

use of org.sonarqube.ws.Ce.ActivityResponse in project sonarqube by SonarSource.

the class ActivityActionTest method search_activity_returns_application.

@Test
public void search_activity_returns_application() {
    ComponentDto apacheApp = db.components().insertPublicApplication(a -> a.setName("Apache App"));
    db.components().insertSnapshot(apacheApp);
    logInAsSystemAdministrator();
    insertActivity("T2", apacheApp, SUCCESS);
    ActivityResponse activityResponse = call(ws.newRequest().setParam(TEXT_QUERY, "apac"));
    assertThat(activityResponse.getTasksList()).extracting(Task::getId).containsOnly("T2");
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 7 with ActivityResponse

use of org.sonarqube.ws.Ce.ActivityResponse in project sonarqube by SonarSource.

the class ActivityAction method handle.

@Override
public void handle(org.sonar.api.server.ws.Request wsRequest, Response wsResponse) throws Exception {
    ActivityResponse activityResponse = doHandle(toSearchWsRequest(wsRequest));
    writeProtobuf(activityResponse, wsRequest, wsResponse);
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse)

Example 8 with ActivityResponse

use of org.sonarqube.ws.Ce.ActivityResponse in project sonarqube by SonarSource.

the class ActivityActionTest method search_task_id_in_activity.

@Test
public void search_task_id_in_activity() {
    logInAsSystemAdministrator();
    ComponentDto project = db.components().insertPrivateProject();
    insertActivity("T1", project, SUCCESS);
    ActivityResponse result = call(ws.newRequest().setParam(Param.TEXT_QUERY, "T1"));
    assertThat(result.getTasksCount()).isOne();
    assertThat(result.getTasks(0).getId()).isEqualTo("T1");
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 9 with ActivityResponse

use of org.sonarqube.ws.Ce.ActivityResponse in project sonarqube by SonarSource.

the class ActivityActionTest method project_administrator_can_access_his_project_activity_using_component_key.

@Test
public void project_administrator_can_access_his_project_activity_using_component_key() {
    ComponentDto project1 = db.components().insertPrivateProject();
    ComponentDto project2 = db.components().insertPrivateProject();
    // no need to be a system admin
    userSession.logIn().addProjectPermission(UserRole.ADMIN, project1);
    insertActivity("T1", project1, SUCCESS);
    insertActivity("T2", project2, FAILED);
    ActivityResponse activityResponse = call(ws.newRequest().setParam("component", project1.getDbKey()));
    assertThat(activityResponse.getTasksCount()).isOne();
    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T1");
    assertThat(activityResponse.getTasks(0).getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS);
    assertThat(activityResponse.getTasks(0).getComponentId()).isEqualTo(project1.uuid());
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 10 with ActivityResponse

use of org.sonarqube.ws.Ce.ActivityResponse in project sonarqube by SonarSource.

the class ActivityActionTest method filter_out_duplicate_tasks_in_progress_and_success.

@Test
public void filter_out_duplicate_tasks_in_progress_and_success() {
    logInAsSystemAdministrator();
    ComponentDto project1 = db.components().insertPrivateProject();
    ComponentDto project2 = db.components().insertPrivateProject();
    ComponentDto project3 = db.components().insertPrivateProject();
    insertQueue("T2", project2, IN_PROGRESS);
    insertQueue("T3", project3, IN_PROGRESS);
    insertActivity("T1", project1, SUCCESS);
    insertActivity("T2", project2, SUCCESS);
    ActivityResponse response = ws.newRequest().setParam("status", "FAILED,IN_PROGRESS,SUCCESS").executeProtobuf(ActivityResponse.class);
    assertThat(response.getTasksList()).extracting(Task::getId).containsExactlyInAnyOrder("T1", "T2", "T3");
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

ActivityResponse (org.sonarqube.ws.Ce.ActivityResponse)23 Test (org.junit.Test)21 ComponentDto (org.sonar.db.component.ComponentDto)18 Ce (org.sonarqube.ws.Ce)5 SnapshotDto (org.sonar.db.component.SnapshotDto)3 CeActivityDto (org.sonar.db.ce.CeActivityDto)2 CeQueueDto (org.sonar.db.ce.CeQueueDto)2 Date (java.util.Date)1 DateUtils.formatDate (org.sonar.api.utils.DateUtils.formatDate)1 Task (org.sonarqube.ws.Ce.Task)1