Search in sources :

Example 11 with ActivityResponse

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

the class ActivityActionTest method search_task_by_component_id.

@Test
public void search_task_by_component_id() {
    ComponentDto project = db.components().insertPrivateProject();
    insertQueue("T1", project, IN_PROGRESS);
    insertActivity("T1", project, SUCCESS);
    userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
    ActivityResponse result = call(ws.newRequest().setParam(PARAM_COMPONENT_ID, project.uuid()).setParam(PARAM_TYPE, CeTaskTypes.REPORT).setParam(PARAM_STATUS, "SUCCESS,FAILED,CANCELED,IN_PROGRESS,PENDING"));
    assertThat(result.getTasksCount()).isOne();
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 12 with ActivityResponse

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

the class ActivityActionTest method pull_request_in_past_activity.

@Test
public void pull_request_in_past_activity() {
    logInAsSystemAdministrator();
    ComponentDto project = db.components().insertPrivateProject();
    userSession.addProjectPermission(UserRole.USER, project);
    ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST));
    SnapshotDto analysis = db.components().insertSnapshot(pullRequest);
    CeActivityDto activity = insertActivity("T1", project, SUCCESS, analysis);
    insertCharacteristic(activity, PULL_REQUEST, pullRequest.getPullRequest());
    ActivityResponse response = ws.newRequest().executeProtobuf(ActivityResponse.class);
    assertThat(response.getTasksList()).extracting(Task::getId, Ce.Task::getPullRequest, Ce.Task::hasPullRequestTitle, Ce.Task::getStatus, Ce.Task::getComponentKey).containsExactlyInAnyOrder(// TODO the pull request title must be loaded from db
    tuple("T1", pullRequest.getPullRequest(), false, Ce.TaskStatus.SUCCESS, pullRequest.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 13 with ActivityResponse

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

the class ActivityActionTest method filter_by_min_submitted_and_max_executed_at_include_day.

@Test
public void filter_by_min_submitted_and_max_executed_at_include_day() {
    logInAsSystemAdministrator();
    ComponentDto project = db.components().insertPrivateProject();
    insertActivity("T1", project, SUCCESS);
    String today = formatDate(new Date(EXECUTED_AT));
    ActivityResponse activityResponse = call(ws.newRequest().setParam(PARAM_MIN_SUBMITTED_AT, today).setParam(PARAM_MAX_EXECUTED_AT, today));
    assertThat(activityResponse.getTasksCount()).isOne();
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) ComponentDto(org.sonar.db.component.ComponentDto) DateUtils.formatDate(org.sonar.api.utils.DateUtils.formatDate) Date(java.util.Date) Test(org.junit.Test)

Example 14 with ActivityResponse

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

the class ActivityActionTest method pull_request_in_queue_analysis.

@Test
public void pull_request_in_queue_analysis() {
    logInAsSystemAdministrator();
    String branch = "pr-123";
    CeQueueDto queue1 = insertQueue("T1", null, IN_PROGRESS);
    insertCharacteristic(queue1, PULL_REQUEST, branch);
    CeQueueDto queue2 = insertQueue("T2", null, PENDING);
    insertCharacteristic(queue2, PULL_REQUEST, branch);
    ActivityResponse response = ws.newRequest().setParam("status", "FAILED,IN_PROGRESS,PENDING").executeProtobuf(ActivityResponse.class);
    assertThat(response.getTasksList()).extracting(Task::getId, Ce.Task::getPullRequest, Ce.Task::hasPullRequestTitle, Ce.Task::getStatus).containsExactlyInAnyOrder(tuple("T1", branch, false, Ce.TaskStatus.IN_PROGRESS), tuple("T2", branch, false, 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 15 with ActivityResponse

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

the class ActivityActionTest method filter_by_max_executed_at_exclude.

@Test
public void filter_by_max_executed_at_exclude() {
    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,SUCCESS").setParam(PARAM_MAX_EXECUTED_AT, "2016-02-15"));
    assertThat(activityResponse.getTasksCount()).isZero();
}
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