RestSession: Remove unnecessary utility methods
Remove the postOK and getOK methods, and corresponding get/post methods that take an 'expectedStatus' argument. They are only used by the CacheOperationsIT tests, and can be easily replaced with calls to RestResponse.assertOK(). Change-Id: I403bf2076b8a93efc63596d837ac25d971ca3fa9 Signed-off-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
@@ -23,7 +23,6 @@ import com.google.gerrit.extensions.restapi.RawInput;
|
||||
import com.google.gerrit.server.OutputFormat;
|
||||
import java.io.IOException;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.fluent.Request;
|
||||
import org.apache.http.entity.BufferedHttpEntity;
|
||||
import org.apache.http.entity.InputStreamEntity;
|
||||
@@ -36,16 +35,6 @@ public class RestSession extends HttpSession {
|
||||
super(server, account);
|
||||
}
|
||||
|
||||
public RestResponse getOK(String endPoint) throws Exception {
|
||||
return get(endPoint, HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
public RestResponse get(String endPoint, int expectedStatus) throws Exception {
|
||||
RestResponse r = get(endPoint);
|
||||
r.assertStatus(expectedStatus);
|
||||
return r;
|
||||
}
|
||||
|
||||
public RestResponse get(String endPoint) throws IOException {
|
||||
return getWithHeader(endPoint, null);
|
||||
}
|
||||
@@ -105,16 +94,6 @@ public class RestSession extends HttpSession {
|
||||
return post(endPoint, null);
|
||||
}
|
||||
|
||||
public RestResponse postOK(String endPoint, Object content) throws Exception {
|
||||
return post(endPoint, content, HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
public RestResponse post(String endPoint, Object content, int expectedStatus) throws Exception {
|
||||
RestResponse r = post(endPoint, content);
|
||||
r.assertStatus(expectedStatus);
|
||||
return r;
|
||||
}
|
||||
|
||||
public RestResponse post(String endPoint, Object content) throws IOException {
|
||||
return postWithHeader(endPoint, null, content);
|
||||
}
|
||||
|
||||
@@ -31,14 +31,17 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flushAll() throws Exception {
|
||||
RestResponse r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
RestResponse r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
|
||||
|
||||
r = adminRestSession.postOK("/config/server/caches/", new PostCaches.Input(FLUSH_ALL));
|
||||
r = adminRestSession.post("/config/server/caches/", new PostCaches.Input(FLUSH_ALL));
|
||||
r.assertOK();
|
||||
r.consume();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isNull();
|
||||
}
|
||||
@@ -59,25 +62,30 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flush() throws Exception {
|
||||
RestResponse r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
RestResponse r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 1);
|
||||
|
||||
r =
|
||||
adminRestSession.postOK(
|
||||
adminRestSession.post(
|
||||
"/config/server/caches/",
|
||||
new PostCaches.Input(FLUSH, Arrays.asList("accounts", "project_list")));
|
||||
r.assertOK();
|
||||
r.consume();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/project_list");
|
||||
r = adminRestSession.get("/config/server/caches/project_list");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isNull();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 1);
|
||||
}
|
||||
@@ -96,7 +104,8 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void flush_UnprocessableEntity() throws Exception {
|
||||
RestResponse r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
RestResponse r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
|
||||
|
||||
@@ -107,7 +116,8 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
r.assertUnprocessableEntity();
|
||||
r.consume();
|
||||
|
||||
r = adminRestSession.getOK("/config/server/caches/projects");
|
||||
r = adminRestSession.get("/config/server/caches/projects");
|
||||
r.assertOK();
|
||||
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
|
||||
}
|
||||
@@ -118,8 +128,9 @@ public class CacheOperationsIT extends AbstractDaemonTest {
|
||||
REGISTERED_USERS, GlobalCapability.FLUSH_CACHES, GlobalCapability.VIEW_CACHES);
|
||||
try {
|
||||
RestResponse r =
|
||||
userRestSession.postOK(
|
||||
userRestSession.post(
|
||||
"/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("projects")));
|
||||
r.assertOK();
|
||||
r.consume();
|
||||
|
||||
userRestSession
|
||||
|
||||
Reference in New Issue
Block a user