use of com.ibm.watson.developer_cloud.service.exception.RequestTooLargeException in project java-sdk by watson-developer-cloud.
the class ErrorResponseTest method testRequestTooLarge.
/**
* Test HTTP status code 413 (RequestTooLarge) error response.
*/
@Test
public void testRequestTooLarge() {
String message = "The request failed because the moon is full.";
server.enqueue(new MockResponse().setResponseCode(413).addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{\"error\": \"" + message + "\"}"));
try {
GenericModel response = service.testMethod().execute();
} catch (Exception e) {
assertTrue(e instanceof RequestTooLargeException);
RequestTooLargeException ex = (RequestTooLargeException) e;
assertEquals(413, ex.getStatusCode());
assertEquals(message, ex.getMessage());
}
}
Aggregations