use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenDeleteEventTypeThenOk.
@Test
public void whenDeleteEventTypeThenOk() throws Exception {
final EventType eventType = buildDefaultEventType();
doReturn(eventType).when(eventTypeRepository).findByName(eventType.getName());
doReturn(Optional.of(eventType)).when(eventTypeRepository).findByNameO(eventType.getName());
doNothing().when(eventTypeRepository).removeEventType(eventType.getName());
final Multimap<TopicRepository, String> topicsToDelete = ArrayListMultimap.create();
topicsToDelete.put(topicRepository, "topic");
doReturn(topicsToDelete).when(timelineService).deleteAllTimelinesForEventType(eventType.getName());
deleteEventType(eventType.getName()).andExpect(status().isOk()).andExpect(content().string(""));
verify(eventTypeRepository, times(1)).removeEventType(eventType.getName());
verify(timelineService, times(1)).deleteAllTimelinesForEventType(eventType.getName());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTthenWarning.
@Test
public void whenPUTthenWarning() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.setPartitionStrategy(PartitionStrategy.RANDOM_STRATEGY);
postEventType(eventType).andExpect(status().isCreated());
final EventType updatedEventType = EventTypeTestBuilder.builder().name(eventType.getName()).partitionStrategy(PartitionStrategy.USER_DEFINED_STRATEGY).createdAt(eventType.getCreatedAt()).build();
doReturn(eventType).when(eventTypeRepository).findByName(any());
putEventType(updatedEventType, eventType.getName()).andExpect(header().string("Warning", "299 nakadi \"I am warning you\""));
}
use of org.zalando.nakadi.domain.EventType 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.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostOptionsRetentionTimeExist.
@Test
public void whenPostOptionsRetentionTimeExist() throws Exception {
final EventType defaultEventType = buildDefaultEventType();
defaultEventType.getOptions().setRetentionTime(TOPIC_RETENTION_TIME_MS);
postEventType(defaultEventType).andExpect(status().is2xxSuccessful());
final ArgumentCaptor<EventTypeBase> eventTypeCaptor = ArgumentCaptor.forClass(EventTypeBase.class);
verify(eventTypeRepository, times(1)).saveEventType(eventTypeCaptor.capture());
assertEquals(TOPIC_RETENTION_TIME_MS, eventTypeCaptor.getValue().getOptions().getRetentionTime().longValue());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostOptionsRetentionTimeSmallerThanMin.
@Test
public void whenPostOptionsRetentionTimeSmallerThanMin() throws Exception {
final EventType defaultEventType = buildDefaultEventType();
defaultEventType.getOptions().setRetentionTime(86399999L);
postEventType(defaultEventType).andExpect(status().is4xxClientError()).andExpect(content().string(new StringContains("Field \\\"options.retention_time\\\" can not be less than 86400000")));
}
Aggregations