use of org.zalando.problem.Problem in project nakadi by zalando.
the class CursorsControllerTest method whenNoEventTypeThenUnprocessableEntity.
@Test
public void whenNoEventTypeThenUnprocessableEntity() throws Exception {
when(cursorsService.commitCursors(any(), any(), any())).thenThrow(new NoSuchEventTypeException("dummy-message"));
final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "dummy-message");
checkForProblem(postCursors(DUMMY_CURSORS), expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class CursorsControllerTest method whenServiceUnavailableExceptionThenServiceUnavailable.
@Test
public void whenServiceUnavailableExceptionThenServiceUnavailable() throws Exception {
when(cursorsService.commitCursors(any(), any(), any())).thenThrow(new ServiceUnavailableException("dummy-message"));
final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE, "dummy-message");
checkForProblem(postCursors(DUMMY_CURSORS), expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class CursorsControllerTest method whenNoSubscriptionThenNotFound.
@Test
public void whenNoSubscriptionThenNotFound() throws Exception {
when(cursorsService.commitCursors(any(), eq(SUBSCRIPTION_ID), any())).thenThrow(new NoSuchSubscriptionException("dummy-message"));
final Problem expectedProblem = Problem.valueOf(NOT_FOUND, "dummy-message");
checkForProblem(postCursors(DUMMY_CURSORS), expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class GzipBodyRequestFilter method reportNotAcceptableError.
private void reportNotAcceptableError(final HttpServletResponse response, final HttpServletRequest request) throws IOException {
response.setStatus(NOT_ACCEPTABLE.getStatusCode());
final PrintWriter writer = response.getWriter();
final Problem problem = Problem.valueOf(NOT_ACCEPTABLE, request.getMethod() + " method doesn't support gzip content encoding");
writer.write(objectMapper.writeValueAsString(problem));
writer.close();
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method whenStreamLimitLowerThanBatchLimitThenUnprocessableEntity.
@Test
public void whenStreamLimitLowerThanBatchLimitThenUnprocessableEntity() throws NakadiException, IOException {
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE);
final StreamingResponseBody responseBody = createStreamingResponseBody(20, 10, 0, 0, 0, null);
final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "stream_limit can't be lower than batch_limit");
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
Aggregations