use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class GetCacheIT method getCache.
@Test
public void getCache() throws Exception {
RestResponse r = adminRestSession.get("/config/server/caches/accounts");
r.assertOK();
CacheInfo result = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(result.name).isEqualTo("accounts");
assertThat(result.type).isEqualTo(CacheType.MEM);
assertThat(result.entries.mem).isAtLeast(1L);
assertThat(result.averageGet).isNotNull();
assertThat(result.averageGet).endsWith("s");
assertThat(result.entries.disk).isNull();
assertThat(result.entries.space).isNull();
assertThat(result.hitRatio.mem).isAtLeast(0);
assertThat(result.hitRatio.mem).isAtMost(100);
assertThat(result.hitRatio.disk).isNull();
userRestSession.get("/config/server/version").consume();
r = adminRestSession.get("/config/server/caches/accounts");
r.assertOK();
result = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(result.entries.mem).isEqualTo(2);
}
use of com.google.gerrit.acceptance.RestResponse 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;
}
use of com.google.gerrit.acceptance.RestResponse 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();
}
use of com.google.gerrit.acceptance.RestResponse 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());
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ListCachesIT method listCacheNamesTextList.
@Test
public void listCacheNamesTextList() throws Exception {
RestResponse r = adminRestSession.get("/config/server/caches/?format=TEXT_LIST");
r.assertOK();
String result = new String(Base64.decode(r.getEntityContent()), UTF_8.name());
List<String> list = Arrays.asList(result.split("\n"));
assertThat(list).contains("accounts");
assertThat(list).contains("projects");
assertThat(Ordering.natural().isOrdered(list)).isTrue();
}
Aggregations