use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeServiceTest method testFailToDeleteEventType.
@Test
public void testFailToDeleteEventType() throws Exception {
final EventType eventType = buildDefaultEventType();
doThrow(new InternalNakadiException("Can't delete event tye")).when(eventTypeRepository).removeEventType(eventType.getName());
doReturn(Optional.of(eventType)).when(eventTypeRepository).findByNameO(eventType.getName());
final Multimap<TopicRepository, String> topicsToDelete = mock(Multimap.class);
doReturn(new ArrayList<Subscription>()).when(subscriptionDbRepository).listSubscriptions(ImmutableSet.of(eventType.getName()), Optional.empty(), 0, 1);
doReturn(topicsToDelete).when(timelineService).deleteAllTimelinesForEventType(eventType.getName());
try {
eventTypeService.delete(eventType.getName());
} catch (final EventTypeDeletionException e) {
// check that topics are not deleted in Kafka
verifyZeroInteractions(topicsToDelete);
return;
}
fail("Should have thrown an EventTypeDeletionException");
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeServiceTest method shouldRemoveEventTypeWhenTimelineCreationFails.
@Test
public void shouldRemoveEventTypeWhenTimelineCreationFails() throws Exception {
final EventType eventType = buildDefaultEventType();
when(timelineService.createDefaultTimeline(anyString(), anyInt(), anyLong())).thenThrow(new TopicCreationException("Failed to create topic"));
try {
eventTypeService.create(eventType);
} catch (final TopicCreationException e) {
}
verify(eventTypeRepository, times(1)).removeEventType(eventType.getName());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeServiceTest method whenEventTypeDeletedThenKPIEventSubmitted.
@Test
public void whenEventTypeDeletedThenKPIEventSubmitted() throws Exception {
final EventType et = buildDefaultEventType();
when(eventTypeRepository.findByNameO(et.getName())).thenReturn(Optional.of(et));
eventTypeService.delete(et.getName());
checkKPIEventSubmitted(nakadiKpiPublisher, KPI_ET_LOG_EVENT_TYPE, new JSONObject().put("event_type", et.getName()).put("status", "deleted").put("category", et.getCategory()).put("authz", "disabled").put("compatibility_mode", et.getCompatibilityMode()));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method eventTypeWithoutSchemaReturns422.
@Test
public void eventTypeWithoutSchemaReturns422() throws Exception {
final EventType invalidEventType = buildDefaultEventType();
invalidEventType.setSchema(null);
final Problem expectedProblem = invalidProblem("schema", "may not be null");
postETAndExpect422WithProblem(invalidEventType, expectedProblem);
}
use of org.zalando.nakadi.domain.EventType 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());
}
Aggregations