use of org.zalando.nakadi.service.subscription.SubscriptionValidationService in project nakadi by zalando.
the class SubscriptionValidationServiceTest method setUp.
@Before
public void setUp() throws InternalNakadiException {
final NakadiSettings nakadiSettings = mock(NakadiSettings.class);
when(nakadiSettings.getMaxSubscriptionPartitions()).thenReturn(MAX_SUBSCRIPTION_PARTITIONS);
topicRepository = mock(TopicRepository.class);
when(topicRepository.listPartitionNames(argThat(isOneOf(topicForET(ET1), topicForET(ET2), topicForET(ET3))))).thenReturn(ImmutableList.of(P0));
etRepo = mock(EventTypeRepository.class);
final Map<String, EventType> eventTypes = new HashMap<>();
for (final String etName : new String[] { ET1, ET2, ET3 }) {
final EventType eventType = new EventType();
eventType.setName(etName);
eventTypes.put(etName, eventType);
}
when(etRepo.findByNameO(any())).thenAnswer(invocation -> Optional.ofNullable(eventTypes.get(invocation.getArguments()[0])));
final TimelineService timelineService = mock(TimelineService.class);
for (final EventType et : eventTypes.values()) {
final Timeline timeline = mock(Timeline.class);
when(timeline.getTopic()).thenReturn(topicForET(et.getName()));
when(timeline.getEventType()).thenReturn(et.getName());
when(timelineService.getActiveTimeline(eq(et.getName()))).thenReturn(timeline);
}
when(timelineService.getTopicRepository((Timeline) any())).thenReturn(topicRepository);
when(timelineService.getTopicRepository((EventType) any())).thenReturn(topicRepository);
cursorConverter = mock(CursorConverter.class);
subscriptionValidationService = new SubscriptionValidationService(timelineService, etRepo, nakadiSettings, cursorConverter);
subscriptionBase = new SubscriptionBase();
subscriptionBase.setEventTypes(ImmutableSet.of(ET1, ET2, ET3));
subscriptionBase.setReadFrom(SubscriptionBase.InitialPosition.CURSORS);
}
Aggregations