use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenPersistencyErrorThen500.
@Test
public void whenPersistencyErrorThen500() throws Exception {
final Problem expectedProblem = Problem.valueOf(Response.Status.INTERNAL_SERVER_ERROR);
doThrow(InternalNakadiException.class).when(eventTypeRepository).saveEventType(any(EventType.class));
postEventType(buildDefaultEventType()).andExpect(status().isInternalServerError()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(matchesProblem(expectedProblem)));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method eventTypeWithoutSchemaReturns422.
@Test
public void eventTypeWithoutSchemaReturns422() throws Exception {
final EventType invalidEventType = buildDefaultEventType();
invalidEventType.setSchema(null);
final Problem expectedProblem = invalidProblem("schema", "may not be null");
postETAndExpect422WithProblem(invalidEventType, expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenPOSTBusinessEventTypeMetadataThen422.
@Test
public void whenPOSTBusinessEventTypeMetadataThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.getSchema().setSchema("{\"type\": \"object\", \"properties\": {\"metadata\": {\"type\": \"object\"} }}");
eventType.setCategory(BUSINESS);
final Problem expectedProblem = new InvalidEventTypeException("\"metadata\" property is reserved").asProblem();
postETAndExpect422WithProblem(eventType, expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenUpdateEventTypeAndTimelineWaitTimeoutThen503.
@Test
public void whenUpdateEventTypeAndTimelineWaitTimeoutThen503() throws Exception {
when(timelineSync.workWithEventType(any(), anyLong())).thenThrow(new TimeoutException());
final EventType eventType = buildDefaultEventType();
final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE, "Event type is currently in maintenance, please repeat request");
putEventType(eventType, eventType.getName(), "nakadi").andExpect(status().isServiceUnavailable()).andExpect(content().string(matchesProblem(expectedProblem)));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenPOSTInvalidSchemaThen422.
@Test
public void whenPOSTInvalidSchemaThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.getSchema().setSchema("{\"not\": {\"type\": \"object\"} }");
eventType.setCategory(BUSINESS);
final Problem expectedProblem = new InvalidEventTypeException("Invalid schema: Invalid schema found in [#]: " + "extraneous key [not] is not permitted").asProblem();
postETAndExpect422WithProblem(eventType, expectedProblem);
}
Aggregations