use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method whenNakadiExceptionIsThrownThenServiceUnavailable.
@Test
public void whenNakadiExceptionIsThrownThenServiceUnavailable() throws NakadiException, IOException {
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenThrow(ServiceUnavailableException.class);
final StreamingResponseBody responseBody = createStreamingResponseBody();
final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE);
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method whenWrongCursorsFormatThenBadRequest.
@Test
public void whenWrongCursorsFormatThenBadRequest() throws NakadiException, IOException {
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE);
final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 0, 0, 0, "cursors_with_wrong_format");
final Problem expectedProblem = Problem.valueOf(BAD_REQUEST, "incorrect syntax of X-nakadi-cursors header");
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method testAccessDenied.
@Test
public void testAccessDenied() throws Exception {
Mockito.doThrow(AccessDeniedException.class).when(authorizationValidator).authorizeStreamRead(any());
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE);
Mockito.doThrow(mockAccessDeniedException()).when(authorizationValidator).authorizeStreamRead(any());
final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 0, 0, 0, null);
final Problem expectedProblem = Problem.valueOf(FORBIDDEN, "Access on READ some-type:some-name denied");
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method whenTopicNotExistsThenTopicNotFound.
@Test
public void whenTopicNotExistsThenTopicNotFound() throws IOException, NakadiException {
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenThrow(NoSuchEventTypeException.class);
final StreamingResponseBody responseBody = createStreamingResponseBody();
final Problem expectedProblem = Problem.valueOf(NOT_FOUND, "topic not found");
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method whenStreamTimeoutLowerThanBatchTimeoutThenUnprocessableEntity.
@Test
public void whenStreamTimeoutLowerThanBatchTimeoutThenUnprocessableEntity() throws NakadiException, IOException {
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE);
final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 20, 10, 0, null);
final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "stream_timeout can't be lower than batch_flush_timeout");
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
Aggregations