Search in sources :

Example 1 with EventTypeOptions

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());
}
Also used : TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) EventTypeOptions(org.zalando.nakadi.domain.EventTypeOptions) Date(java.util.Date) Test(org.junit.Test)

Example 2 with EventTypeOptions

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());
}
Also used : EventTypeOptions(org.zalando.nakadi.domain.EventTypeOptions) Test(org.junit.Test)

Example 3 with EventTypeOptions

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);
}
Also used : EventTypeOptions(org.zalando.nakadi.domain.EventTypeOptions)

Example 4 with EventTypeOptions

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());
    }
}
Also used : EventTypeOptions(org.zalando.nakadi.domain.EventTypeOptions)

Example 5 with EventTypeOptions

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());
}
Also used : TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) EventTypeOptions(org.zalando.nakadi.domain.EventTypeOptions) Date(java.util.Date) Test(org.junit.Test)

Aggregations

EventTypeOptions (org.zalando.nakadi.domain.EventTypeOptions)6 Test (org.junit.Test)3 Date (java.util.Date)2 EventType (org.zalando.nakadi.domain.EventType)2 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)2