use of org.zalando.nakadi.domain.EventTypeOptions in project nakadi by zalando.
the class EventTypeControllerTest method whenUpdateRetentionTimeAndKafkaFails.
@Test
public void whenUpdateRetentionTimeAndKafkaFails() throws Exception {
final EventType eventType = EventTypeTestBuilder.builder().build();
final EventTypeOptions eventTypeOptions = new EventTypeOptions();
eventTypeOptions.setRetentionTime(172800000L);
eventType.setOptions(eventTypeOptions);
doReturn(eventType).when(eventTypeRepository).findByName(eventType.getName());
doThrow(TopicConfigException.class).when(topicRepository).setRetentionTime(anyString(), anyLong());
when(timelineService.getActiveTimelinesOrdered(any())).thenReturn(Collections.singletonList(Timeline.createTimeline(eventType.getName(), 0, null, "topic", new Date())));
final EventType eventType2 = EventTypeTestBuilder.builder().name(eventType.getName()).build();
final EventTypeOptions eventTypeOptions2 = new EventTypeOptions();
eventTypeOptions2.setRetentionTime(172800001L);
eventType2.setOptions(eventTypeOptions2);
putEventType(eventType2, eventType2.getName(), "nakadi").andExpect(status().isInternalServerError());
verify(topicRepository, times(2)).setRetentionTime(anyString(), anyLong());
verify(eventTypeRepository, times(0)).update(any());
}
use of org.zalando.nakadi.domain.EventTypeOptions in project nakadi by zalando.
the class EventTypeOptionsValidatorTest method testValidation.
@Test
public void testValidation() {
final EventTypeOptions eventTypeOptions = new EventTypeOptions();
validator.validate(eventTypeOptions, mockedErrors);
Mockito.verify(mockedErrors, Mockito.times(0)).rejectValue(Matchers.any(), Matchers.any(), Matchers.any());
}
use of org.zalando.nakadi.domain.EventTypeOptions in project nakadi by zalando.
the class EventTypeOptionsValidator method validate.
@Override
public void validate(final Object target, final Errors errors) {
final EventTypeOptions options = (EventTypeOptions) target;
checkRetentionTime(errors, options);
}
use of org.zalando.nakadi.domain.EventTypeOptions in project nakadi by zalando.
the class EventTypeService method setDefaultEventTypeOptions.
private void setDefaultEventTypeOptions(final EventTypeBase eventType) {
final EventTypeOptions options = eventType.getOptions();
if (options == null) {
final EventTypeOptions eventTypeOptions = new EventTypeOptions();
eventTypeOptions.setRetentionTime(nakadiSettings.getDefaultTopicRetentionMs());
eventType.setOptions(eventTypeOptions);
} else if (options.getRetentionTime() == null) {
options.setRetentionTime(nakadiSettings.getDefaultTopicRetentionMs());
}
}
use of org.zalando.nakadi.domain.EventTypeOptions in project nakadi by zalando.
the class EventTypeControllerTest method whenUpdateRetentionTimeAndDbFails.
@Test
public void whenUpdateRetentionTimeAndDbFails() throws Exception {
final EventType eventType = EventTypeTestBuilder.builder().build();
final EventTypeOptions eventTypeOptions = new EventTypeOptions();
eventTypeOptions.setRetentionTime(172800000L);
eventType.setOptions(eventTypeOptions);
doReturn(eventType).when(eventTypeRepository).findByName(eventType.getName());
doThrow(InternalNakadiException.class).when(eventTypeRepository).update(any());
when(timelineService.getActiveTimelinesOrdered(any())).thenReturn(Collections.singletonList(Timeline.createTimeline(eventType.getName(), 0, null, "topic", new Date())));
final EventType eventType2 = EventTypeTestBuilder.builder().name(eventType.getName()).build();
final EventTypeOptions eventTypeOptions2 = new EventTypeOptions();
eventTypeOptions2.setRetentionTime(172800001L);
eventType2.setOptions(eventTypeOptions2);
putEventType(eventType2, eventType2.getName(), "nakadi").andExpect(status().isInternalServerError());
verify(topicRepository, times(2)).setRetentionTime(anyString(), anyLong());
verify(eventTypeRepository).update(any());
}
Aggregations