use of org.zalando.nakadi.domain.EventType 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.nakadi.domain.EventType 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);
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTWithInvalidEnrichmentStrategyThen422.
@Test
public void whenPUTWithInvalidEnrichmentStrategyThen422() throws Exception {
final EventTypeTestBuilder builder = EventTypeTestBuilder.builder();
builder.enrichmentStrategies(Lists.newArrayList(EnrichmentStrategyDescriptor.METADATA_ENRICHMENT));
final EventType original = builder.build();
builder.enrichmentStrategies(new ArrayList<>());
final EventType update = builder.build();
doReturn(original).when(eventTypeRepository).findByName(any());
putEventType(update, update.getName()).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json"));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenCreateSuccessfullyThen201.
@Test
public void whenCreateSuccessfullyThen201() throws Exception {
final EventType et = buildDefaultEventType();
final Timeline timeline = buildTimelineWithTopic("topic1");
when(timelineService.createDefaultTimeline(anyString(), anyInt(), anyLong())).thenReturn(timeline);
doReturn(et).when(eventTypeRepository).saveEventType(any(EventType.class));
postEventType(et).andExpect(status().isCreated()).andExpect(content().string(""));
verify(eventTypeRepository, times(1)).saveEventType(any(EventType.class));
verify(timelineService, times(1)).createDefaultTimeline(anyString(), anyInt(), anyLong());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTEventTypeWithWrongPartitionKeyFieldsThen422.
@Test
public void whenPUTEventTypeWithWrongPartitionKeyFieldsThen422() throws Exception {
final EventType eventType = EventTypeTestBuilder.builder().partitionKeyFields(Collections.singletonList("blabla")).build();
doReturn(eventType).when(eventTypeRepository).findByName(eventType.getName());
putEventType(eventType, eventType.getName()).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json"));
}
Aggregations