Search in sources :

Example 66 with RestResponse

use of com.google.gerrit.acceptance.RestResponse 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)

Example 67 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class ListTasksIT method listTasksWithoutViewQueueCapability.

@Test
public void listTasksWithoutViewQueueCapability() throws Exception {
    RestResponse r = userRestSession.get("/config/server/tasks/");
    r.assertOK();
    List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
    }.getType());
    assertThat(result).isEmpty();
}
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 68 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class GroupsIT method invalidQueryOptions.

@Test
public void invalidQueryOptions() throws Exception {
    RestResponse r = adminRestSession.put("/groups/?query=foo&query2=bar");
    r.assertBadRequest();
    assertThat(r.getEntityContent()).isEqualTo("\"query\" and \"query2\" options are mutually exclusive");
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 69 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class TopicIT method topic.

@Test
public void topic() throws Exception {
    Result result = createChange();
    String endpoint = "/changes/" + result.getChangeId() + "/topic";
    RestResponse response = adminRestSession.put(endpoint, "topic");
    response.assertOK();
    response = adminRestSession.delete(endpoint);
    response.assertNoContent();
    response = adminRestSession.put(endpoint, "topic");
    response.assertOK();
    response = adminRestSession.put(endpoint, "");
    response.assertNoContent();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) Result(com.google.gerrit.acceptance.PushOneCommit.Result) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 70 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class CacheOperationsIT method flush.

@Test
public void flush() throws Exception {
    RestResponse r = adminRestSession.getOK("/config/server/caches/project_list");
    CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
    assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
    r = adminRestSession.getOK("/config/server/caches/projects");
    cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
    assertThat(cacheInfo.entries.mem).isGreaterThan((long) 1);
    r = adminRestSession.postOK("/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("accounts", "project_list")));
    r.consume();
    r = adminRestSession.getOK("/config/server/caches/project_list");
    cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
    assertThat(cacheInfo.entries.mem).isNull();
    r = adminRestSession.getOK("/config/server/caches/projects");
    cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
    assertThat(cacheInfo.entries.mem).isGreaterThan((long) 1);
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) CacheInfo(com.google.gerrit.server.config.ListCaches.CacheInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

RestResponse (com.google.gerrit.acceptance.RestResponse)79 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)67 Test (org.junit.Test)67 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)17 TypeToken (com.google.gson.reflect.TypeToken)15 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)9 CacheInfo (com.google.gerrit.server.config.ListCaches.CacheInfo)6 TaskInfo (com.google.gerrit.server.config.ListTasks.TaskInfo)6 ReviewResult (com.google.gerrit.extensions.api.changes.ReviewResult)5 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)5 Result (com.google.gerrit.acceptance.PushOneCommit.Result)4 AccountExternalIdInfo (com.google.gerrit.extensions.common.AccountExternalIdInfo)4 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)4 ArrayList (java.util.ArrayList)4 ApprovalInfo (com.google.gerrit.extensions.common.ApprovalInfo)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)2 EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)2 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)2 PublishChangeEditInput (com.google.gerrit.extensions.api.changes.PublishChangeEditInput)2