Search in sources :

Example 1 with TaskInfo

use of com.google.gerrit.server.config.ListTasks.TaskInfo in project gerrit by GerritCodeReview.

the class KillTaskIT method killTask_NotFound.

private void killTask_NotFound() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/");
    List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    r.consume();
    assertThat(result.size()).isGreaterThan(0);
    userRestSession.delete("/config/server/tasks/" + result.get(0).id).assertNotFound();
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken)

Example 2 with TaskInfo

use of com.google.gerrit.server.config.ListTasks.TaskInfo in project gerrit by GerritCodeReview.

the class GetTaskIT method getLogFileCompressorTaskId.

private String getLogFileCompressorTaskId() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/");
    List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    r.consume();
    for (TaskInfo info : result) {
        if ("Log File Compressor".equals(info.command)) {
            return info.id;
        }
    }
    return null;
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken)

Example 3 with TaskInfo

use of com.google.gerrit.server.config.ListTasks.TaskInfo in project gerrit by GerritCodeReview.

the class GetTaskIT method getTask.

@Test
public void getTask() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/" + getLogFileCompressorTaskId());
    r.assertOK();
    TaskInfo info = newGson().fromJson(r.getReader(), new TypeToken<TaskInfo>() {
    }.getType());
    assertThat(info.id).isNotNull();
    Long.parseLong(info.id, 16);
    assertThat(info.command).isEqualTo("Log File Compressor");
    assertThat(info.startTime).isNotNull();
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with TaskInfo

use of com.google.gerrit.server.config.ListTasks.TaskInfo in project gerrit by GerritCodeReview.

the class KillTaskIT method killTask.

private void killTask() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/");
    List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    r.consume();
    Optional<String> id = result.stream().filter(t -> "Log File Compressor".equals(t.command)).map(t -> t.id).findFirst();
    assertThat(id).isPresent();
    r = adminRestSession.delete("/config/server/tasks/" + id.get());
    r.assertNoContent();
    r.consume();
    r = adminRestSession.get("/config/server/tasks/");
    result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    r.consume();
    Set<String> ids = result.stream().map(t -> t.id).collect(toSet());
    assertThat(ids).doesNotContain(id.get());
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) List(java.util.List) TypeToken(com.google.gson.reflect.TypeToken) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) RestResponse(com.google.gerrit.acceptance.RestResponse) Optional(java.util.Optional) Set(java.util.Set) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Collectors.toSet(java.util.stream.Collectors.toSet) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) List(java.util.List)

Example 5 with TaskInfo

use of com.google.gerrit.server.config.ListTasks.TaskInfo in project gerrit by GerritCodeReview.

the class ListTasksIT method listTasks.

@Test
public void listTasks() throws Exception {
    RestResponse r = adminRestSession.get("/config/server/tasks/");
    r.assertOK();
    List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    assertThat(result).isNotEmpty();
    boolean foundLogFileCompressorTask = false;
    for (TaskInfo info : result) {
        if ("Log File Compressor".equals(info.command)) {
            foundLogFileCompressorTask = true;
        }
        assertThat(info.id).isNotNull();
        Long.parseLong(info.id, 16);
        assertThat(info.command).isNotNull();
        assertThat(info.startTime).isNotNull();
    }
    assertThat(foundLogFileCompressorTask).isTrue();
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

TaskInfo (com.google.gerrit.server.config.ListTasks.TaskInfo)7 RestResponse (com.google.gerrit.acceptance.RestResponse)6 TypeToken (com.google.gson.reflect.TypeToken)6 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 Test (org.junit.Test)4 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1