use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenDeleteEventTypeAndTimelineWaitTimeoutThen503.
@Test
public void whenDeleteEventTypeAndTimelineWaitTimeoutThen503() throws Exception {
when(timelineSync.workWithEventType(any(), anyLong())).thenThrow(new TimeoutException());
final EventType eventType = buildDefaultEventType();
final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE, "Event type " + eventType.getName() + " is currently in maintenance, please repeat request");
deleteEventType(eventType.getName()).andExpect(status().isServiceUnavailable()).andExpect(content().string(matchesProblem(expectedProblem)));
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenTimelineCreationFailsRemoveEventTypeFromRepositoryAnd500.
@Test
public void whenTimelineCreationFailsRemoveEventTypeFromRepositoryAnd500() throws Exception {
final EventType et = buildDefaultEventType();
doThrow(TopicCreationException.class).when(timelineService).createDefaultTimeline(anyString(), anyInt(), anyLong());
final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE);
postEventType(et).andExpect(status().isServiceUnavailable()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(matchesProblem(expectedProblem)));
verify(eventTypeRepository, times(1)).saveEventType(any(EventType.class));
verify(timelineService, times(1)).createDefaultTimeline(anyString(), anyInt(), anyLong());
verify(eventTypeRepository, times(1)).removeEventType(et.getName());
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTNotExistingEventTypeThen404.
@Test
public void whenPUTNotExistingEventTypeThen404() throws Exception {
final EventType eventType = buildDefaultEventType();
final Problem expectedProblem = Problem.valueOf(NOT_FOUND);
doThrow(NoSuchEventTypeException.class).when(eventTypeRepository).findByName(eventType.getName());
putEventType(eventType, eventType.getName()).andExpect(status().isNotFound()).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 whenPostDuplicatedEventTypeReturn409.
@Test
public void whenPostDuplicatedEventTypeReturn409() throws Exception {
final Problem expectedProblem = Problem.valueOf(Response.Status.CONFLICT, "some-name");
doThrow(new DuplicatedEventTypeNameException("some-name")).when(eventTypeRepository).saveEventType(any(EventTypeBase.class));
postEventType(buildDefaultEventType()).andExpect(status().isConflict()).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 whenPUTRepoNakadiExceptionThen422.
@Test
public void whenPUTRepoNakadiExceptionThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
final Problem expectedProblem = Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY);
doThrow(UnprocessableEntityException.class).when(eventTypeRepository).findByName(eventType.getName());
putEventType(eventType, eventType.getName()).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(matchesProblem(expectedProblem)));
}
Aggregations