use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method whenInvalidCursorsThenPreconditionFailed.
@Test
public void whenInvalidCursorsThenPreconditionFailed() throws Exception {
final NakadiCursor cursor = NakadiCursor.of(timeline, "0", "000000000000000000");
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE);
when(timelineService.createEventConsumer(eq(KAFKA_CLIENT_ID), any())).thenThrow(new InvalidCursorException(CursorError.UNAVAILABLE, cursor));
final StreamingResponseBody responseBody = createStreamingResponseBody(1, 0, 0, 0, 0, "[{\"partition\":\"0\",\"offset\":\"00000000000000000\"}]");
final Problem expectedProblem = Problem.valueOf(PRECONDITION_FAILED, "offset 000000000000000000 for partition 0 is 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 whenBatchLimitLowerThan1ThenUnprocessableEntity.
@Test
public void whenBatchLimitLowerThan1ThenUnprocessableEntity() throws NakadiException, IOException {
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenReturn(EVENT_TYPE);
final StreamingResponseBody responseBody = createStreamingResponseBody(0, 0, 0, 0, 0, null);
final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "batch_limit can't be lower than 1");
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventStreamControllerTest method whenExceptionIsThrownThenInternalServerError.
@Test
public void whenExceptionIsThrownThenInternalServerError() throws NakadiException, IOException {
when(eventTypeRepository.findByName(TEST_EVENT_TYPE_NAME)).thenThrow(NullPointerException.class);
final StreamingResponseBody responseBody = createStreamingResponseBody();
final Problem expectedProblem = Problem.valueOf(INTERNAL_SERVER_ERROR);
assertThat(responseToString(responseBody), TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenPostWithEventTypeNameNotSetThenReturn422.
@Test
public void whenPostWithEventTypeNameNotSetThenReturn422() throws Exception {
final EventType invalidEventType = buildDefaultEventType();
invalidEventType.setName(null);
final Problem expectedProblem = invalidProblem("name", "may not be null");
postETAndExpect422WithProblem(invalidEventType, expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenPostWithNoSchemaSchemaThenReturn422.
@Test
public void whenPostWithNoSchemaSchemaThenReturn422() throws Exception {
final Problem expectedProblem = invalidProblem("schema.schema", "may not be null");
final String eventType = "{\"category\": \"data\", \"owning_application\": \"blah-app\", " + "\"name\": \"blah-event-type\", \"schema\": { \"type\": \"JSON_SCHEMA\" }}";
postETAndExpect422WithProblem(eventType, expectedProblem);
}
Aggregations