use of com.github.ambry.rest.MockRestResponseChannel in project ambry by linkedin.
the class UndeleteHandlerTest method verifyFailureWithErrorCode.
/**
* Verifies that processing {@code restRequest} fails with {@code errorCode}
* @param restRequest the {@link RestRequest} that is expected to fail
* @param errorCode the {@link RestServiceErrorCode} that it should fail with
* @throws Exception
*/
private void verifyFailureWithErrorCode(RestRequest restRequest, RestServiceErrorCode errorCode) throws Exception {
try {
sendRequestGetResponse(restRequest, new MockRestResponseChannel());
fail("Request should have failed");
} catch (RestServiceException e) {
assertEquals("Unexpected RestServiceErrorCode", errorCode, e.getErrorCode());
}
}
use of com.github.ambry.rest.MockRestResponseChannel 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;
}
}
}
Aggregations