Search in sources :

Example 1 with ActivityResponse

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

the class ActivityActionTest method search_task_id_in_queue_ignoring_other_parameters.

@Test
public void search_task_id_in_queue_ignoring_other_parameters() {
    logInAsSystemAdministrator();
    ComponentDto project = db.components().insertPrivateProject();
    insertQueue("T1", project, IN_PROGRESS);
    ActivityResponse result = call(ws.newRequest().setParam(Param.TEXT_QUERY, "T1").setParam(PARAM_STATUS, PENDING.name()));
    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 2 with ActivityResponse

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

the class ActivityActionTest method branch_in_past_activity.

@Test
public void branch_in_past_activity() {
    logInAsSystemAdministrator();
    ComponentDto project = db.components().insertPrivateProject();
    userSession.addProjectPermission(UserRole.USER, project);
    ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
    SnapshotDto analysis = db.components().insertSnapshot(branch);
    CeActivityDto activity = insertActivity("T1", project, SUCCESS, analysis);
    insertCharacteristic(activity, BRANCH_KEY, branch.getBranch());
    insertCharacteristic(activity, BRANCH_TYPE_KEY, BRANCH.name());
    ActivityResponse response = ws.newRequest().executeProtobuf(ActivityResponse.class);
    assertThat(response.getTasksList()).extracting(Task::getId, Ce.Task::getBranch, Ce.Task::getBranchType, Ce.Task::getStatus, Ce.Task::getComponentKey).containsExactlyInAnyOrder(tuple("T1", branch.getBranch(), Common.BranchType.BRANCH, Ce.TaskStatus.SUCCESS, branch.getKey()));
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) Ce(org.sonarqube.ws.Ce) CeActivityDto(org.sonar.db.ce.CeActivityDto) SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 3 with ActivityResponse

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

the class ActivityActionTest method return_warnings_count_on_queue_and_activity_but_no_warnings_list.

@Test
public void return_warnings_count_on_queue_and_activity_but_no_warnings_list() {
    logInAsSystemAdministrator();
    ComponentDto project1 = db.components().insertPrivateProject();
    ComponentDto project2 = db.components().insertPrivateProject();
    insertActivity("T1", project1, SUCCESS);
    insertActivity("T2", project2, FAILED);
    insertQueue("T3", project1, IN_PROGRESS);
    insertMessages("T1", 2);
    insertMessages("T2", 0);
    insertMessages("T3", 5);
    ActivityResponse activityResponse = call(ws.newRequest().setParam(Param.PAGE_SIZE, Integer.toString(10)).setParam(PARAM_STATUS, "SUCCESS,FAILED,CANCELED,IN_PROGRESS,PENDING"));
    assertThat(activityResponse.getTasksList()).extracting(Task::getId, Task::getWarningCount, Task::getWarningsList).containsOnly(tuple("T1", 2, emptyList()), tuple("T2", 0, emptyList()), tuple("T3", 0, emptyList()));
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 4 with ActivityResponse

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

the class ActivityActionTest method search_activity_returns_views.

@Test
public void search_activity_returns_views() {
    ComponentDto apacheView = db.components().insertPrivatePortfolio(v -> v.setName("Apache View"));
    db.components().insertSnapshot(apacheView);
    logInAsSystemAdministrator();
    insertActivity("T2", apacheView, SUCCESS);
    ActivityResponse activityResponse = call(ws.newRequest().setParam(TEXT_QUERY, "apac"));
    assertThat(activityResponse.getTasksList()).extracting("id").containsOnly("T2");
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 5 with ActivityResponse

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

the class ActivityActionTest method filter_on_current_activities.

@Test
public void filter_on_current_activities() {
    logInAsSystemAdministrator();
    ComponentDto project = db.components().insertPrivateProject();
    // T2 is the current activity (the most recent one)
    insertActivity("T1", project, SUCCESS);
    insertActivity("T2", project, FAILED);
    insertQueue("T3", project, PENDING);
    ActivityResponse activityResponse = call(ws.newRequest().setParam("onlyCurrents", "true"));
    assertThat(activityResponse.getTasksCount()).isOne();
    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T2");
}
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