Search in sources :

Example 16 with ActivityResponse

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

the class ActivityActionTest method filter_by_status.

@Test
public void filter_by_status() {
    logInAsSystemAdministrator();
    ComponentDto project1 = db.components().insertPrivateProject();
    ComponentDto project2 = db.components().insertPrivateProject();
    insertActivity("T1", project1, SUCCESS);
    insertActivity("T2", project2, FAILED);
    insertQueue("T3", project1, IN_PROGRESS);
    ActivityResponse activityResponse = call(ws.newRequest().setParam("status", "FAILED,IN_PROGRESS"));
    assertThat(activityResponse.getTasksCount()).isEqualTo(2);
    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T3");
    assertThat(activityResponse.getTasks(1).getId()).isEqualTo("T2");
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 17 with ActivityResponse

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

the class ActivityActionTest method branch_in_queue_analysis.

@Test
public void branch_in_queue_analysis() {
    logInAsSystemAdministrator();
    String branch = "ny_branch";
    CeQueueDto queue1 = insertQueue("T1", null, IN_PROGRESS);
    insertCharacteristic(queue1, BRANCH_KEY, branch);
    insertCharacteristic(queue1, BRANCH_TYPE_KEY, BRANCH.name());
    CeQueueDto queue2 = insertQueue("T2", null, PENDING);
    insertCharacteristic(queue2, BRANCH_KEY, branch);
    insertCharacteristic(queue2, BRANCH_TYPE_KEY, BRANCH.name());
    ActivityResponse response = ws.newRequest().setParam("status", "FAILED,IN_PROGRESS,PENDING").executeProtobuf(ActivityResponse.class);
    assertThat(response.getTasksList()).extracting(Task::getId, Ce.Task::getBranch, Ce.Task::getBranchType, Ce.Task::getStatus).containsExactlyInAnyOrder(tuple("T1", branch, Common.BranchType.BRANCH, Ce.TaskStatus.IN_PROGRESS), tuple("T2", branch, Common.BranchType.BRANCH, Ce.TaskStatus.PENDING));
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) Ce(org.sonarqube.ws.Ce) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 18 with ActivityResponse

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

the class ActivityActionTest method get_all_past_activity.

@Test
public void get_all_past_activity() {
    logInAsSystemAdministrator();
    ComponentDto project1 = db.components().insertPrivateProject();
    ComponentDto project2 = db.components().insertPrivateProject();
    SnapshotDto analysisProject1 = db.components().insertSnapshot(project1);
    insertActivity("T1", project1, SUCCESS, analysisProject1);
    insertActivity("T2", project2, FAILED, null);
    ActivityResponse activityResponse = call(ws.newRequest().setParam(PARAM_MAX_EXECUTED_AT, formatDateTime(EXECUTED_AT + 2_000)));
    assertThat(activityResponse.getTasksCount()).isEqualTo(2);
    // chronological order, from newest to oldest
    Task task = activityResponse.getTasks(0);
    assertThat(task.getId()).isEqualTo("T2");
    assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.FAILED);
    assertThat(task.getComponentId()).isEqualTo(project2.uuid());
    assertThat(task.hasAnalysisId()).isFalse();
    assertThat(task.getExecutionTimeMs()).isEqualTo(500L);
    assertThat(task.getWarningCount()).isZero();
    task = activityResponse.getTasks(1);
    assertThat(task.getId()).isEqualTo("T1");
    assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS);
    assertThat(task.getComponentId()).isEqualTo(project1.uuid());
    assertThat(task.getWarningCount()).isZero();
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) Task(org.sonarqube.ws.Ce.Task) SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 19 with ActivityResponse

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

the class ActivityActionTest method search_activity_by_component_name.

@Test
public void search_activity_by_component_name() {
    ComponentDto struts = db.components().insertPrivateProject(c -> c.setName("old apache struts"));
    ComponentDto zookeeper = db.components().insertPrivateProject(c -> c.setName("new apache zookeeper"));
    ComponentDto eclipse = db.components().insertPrivateProject(c -> c.setName("eclipse"));
    db.components().insertSnapshot(struts);
    db.components().insertSnapshot(zookeeper);
    db.components().insertSnapshot(eclipse);
    logInAsSystemAdministrator();
    insertActivity("T1", struts, SUCCESS);
    insertActivity("T2", zookeeper, SUCCESS);
    insertActivity("T3", eclipse, SUCCESS);
    ActivityResponse activityResponse = call(ws.newRequest().setParam(TEXT_QUERY, "apac"));
    assertThat(activityResponse.getTasksList()).extracting("id").containsOnly("T1", "T2");
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 20 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_id.

@Test
public void project_administrator_can_access_his_project_activity_using_component_id() {
    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("componentId", project1.uuid()));
    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)

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