use of com.github.ambry.rest.MockRestRequest in project ambry by linkedin.
the class GetStatsReportHandlerTest method createRestRequest.
// Helpers
private RestRequest createRestRequest(String clusterName, String reportType) throws Exception {
JSONObject data = new JSONObject();
data.put(MockRestRequest.REST_METHOD_KEY, RestMethod.GET.name());
data.put(MockRestRequest.URI_KEY, Operations.STATS_REPORT);
JSONObject headers = new JSONObject();
if (reportType != null) {
headers.put(RestUtils.Headers.GET_STATS_REPORT_TYPE, reportType);
}
if (clusterName != null) {
headers.put(RestUtils.Headers.CLUSTER_NAME, clusterName);
}
data.put(MockRestRequest.HEADERS_KEY, headers);
return new MockRestRequest(data, null);
}
use of com.github.ambry.rest.MockRestRequest in project ambry by linkedin.
the class TtlUpdateHandlerTest method handleGoodCaseTest.
/**
* Tests the case where TTL update succeeds
* @throws Exception
*/
@Test
public void handleGoodCaseTest() throws Exception {
RestRequest restRequest = new MockRestRequest(MockRestRequest.DUMMY_DATA, null);
restRequest.setArg(RestUtils.Headers.BLOB_ID, blobId);
restRequest.setArg(RestUtils.Headers.SERVICE_ID, SERVICE_ID);
verifyTtlUpdate(restRequest, REF_ACCOUNT, REF_CONTAINER);
}
use of com.github.ambry.rest.MockRestRequest in project ambry by linkedin.
the class TtlUpdateHandlerTest method verifyFailureWithMsg.
/**
* Verifies that attempting to update TTL fails with the provided {@code msg}.
* @param msg the message in the {@link Exception} that will be thrown.
* @throws Exception
*/
private void verifyFailureWithMsg(String msg) throws Exception {
RestRequest restRequest = new MockRestRequest(MockRestRequest.DUMMY_DATA, null);
restRequest.setArg(RestUtils.Headers.BLOB_ID, blobId);
restRequest.setArg(RestUtils.Headers.SERVICE_ID, SERVICE_ID);
try {
sendRequestGetResponse(restRequest, new MockRestResponseChannel());
fail("Request should have failed");
} catch (Exception e) {
if (!msg.equals(e.getMessage())) {
throw e;
}
}
}
use of com.github.ambry.rest.MockRestRequest in project ambry by linkedin.
the class UndeleteHandlerTest method verifyFailureWithMsg.
/**
* Verifies that attempting to undelete fails with the provided {@code msg}.
* @param msg the message in the {@link Exception} that will be thrown.
* @throws Exception
*/
private void verifyFailureWithMsg(String msg) throws Exception {
RestRequest restRequest = new MockRestRequest(MockRestRequest.DUMMY_DATA, null);
restRequest.setArg(RestUtils.Headers.BLOB_ID, blobId);
restRequest.setArg(RestUtils.Headers.SERVICE_ID, SERVICE_ID);
try {
sendRequestGetResponse(restRequest, new MockRestResponseChannel());
fail("Request should have failed");
} catch (Exception e) {
if (!msg.equals(e.getMessage())) {
throw e;
}
}
}
use of com.github.ambry.rest.MockRestRequest in project ambry by linkedin.
the class GetClusterMapSnapshotHandlerTest method createRestRequest.
// helpers
// general
/**
* Creates a {@link RestRequest} that requests for a snapshot of the cluster map.
* @return a {@link RestRequest} that requests for a snapshot of the cluster map.
* @throws Exception
*/
private RestRequest createRestRequest() throws Exception {
JSONObject data = new JSONObject();
data.put(MockRestRequest.REST_METHOD_KEY, RestMethod.GET.name());
data.put(MockRestRequest.URI_KEY, Operations.GET_CLUSTER_MAP_SNAPSHOT);
return new MockRestRequest(data, null);
}
Aggregations