use of org.zalando.nakadi.util.UUIDGenerator in project nakadi by zalando.
the class CursorsServiceAT method before.
@Before
public void before() throws Exception {
sid = randomUUID();
streamId = randomUUID();
etName = randomValidEventTypeName();
topic = randomUUID();
cursorConverter = mock(CursorConverter.class);
testCursors = ImmutableList.of(NakadiCursor.of(buildTimeline(etName, topic, CREATED_AT), P1, NEW_OFFSET));
final EventType eventType = mock(EventType.class);
when(eventType.getName()).thenReturn(etName);
final ZooKeeperHolder zkHolder = mock(ZooKeeperHolder.class);
when(zkHolder.get()).thenReturn(CURATOR);
final TopicRepository topicRepository = mock(TopicRepository.class);
final TimelineService timelineService = mock(TimelineService.class);
when(timelineService.getTopicRepository((Timeline) any())).thenReturn(topicRepository);
timeline = buildTimeline(etName, topic, CREATED_AT);
when(timelineService.getActiveTimeline(any(EventType.class))).thenReturn(timeline);
final Subscription subscription = mock(Subscription.class);
when(subscription.getId()).thenReturn(sid);
when(subscription.getEventTypes()).thenReturn(ImmutableSet.of(etName));
final SubscriptionDbRepository subscriptionRepo = mock(SubscriptionDbRepository.class);
when(subscriptionRepo.getSubscription(sid)).thenReturn(subscription);
final SubscriptionClientFactory zkSubscriptionFactory = new SubscriptionClientFactory(zkHolder, MAPPER);
uuidGenerator = mock(UUIDGenerator.class);
when(uuidGenerator.isUUID(any())).thenReturn(true);
cursorsService = new CursorsService(subscriptionRepo, null, mock(NakadiSettings.class), zkSubscriptionFactory, cursorConverter, uuidGenerator, null);
// Register cursors in converter
registerNakadiCursor(NakadiCursor.of(buildTimeline(etName, topic, CREATED_AT), P1, NEW_OFFSET));
registerNakadiCursor(NakadiCursor.of(buildTimeline(etName, topic, CREATED_AT), P1, OLD_OFFSET));
registerNakadiCursor(NakadiCursor.of(buildTimeline(etName, topic, CREATED_AT), P2, NEW_OFFSET));
registerNakadiCursor(NakadiCursor.of(buildTimeline(etName, topic, CREATED_AT), P2, OLD_OFFSET));
// bootstrap data in ZK
CURATOR.create().creatingParentsIfNeeded().forPath(offsetPath(P1), OLD_OFFSET.getBytes(UTF_8));
CURATOR.create().creatingParentsIfNeeded().forPath(offsetPath(P2), OLD_OFFSET.getBytes(UTF_8));
CURATOR.create().creatingParentsIfNeeded().forPath(sessionPath(streamId));
}
use of org.zalando.nakadi.util.UUIDGenerator in project nakadi by zalando.
the class TimelineSyncAT method createTimeline.
private TimelineSyncImpl createTimeline() throws InterruptedException {
if (null == uuidGenerator) {
uuidGenerator = new UUIDGenerator();
}
if (null == zookeeperHolder) {
zookeeperHolder = Mockito.mock(ZooKeeperHolder.class);
Mockito.when(zookeeperHolder.get()).thenReturn(CURATOR);
}
final TimelineSyncImpl result = new TimelineSyncImpl(zookeeperHolder, uuidGenerator);
synchronized (DELAYED_RUNS) {
DELAYED_RUNS.add(() -> {
try {
result.reactOnEventTypesChange();
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
}
});
}
return result;
}
use of org.zalando.nakadi.util.UUIDGenerator in project nakadi by zalando.
the class KafkaRepositoryAT method createKafkaTopicRepository.
private KafkaTopicRepository createKafkaTopicRepository() {
final CuratorZookeeperClient zookeeperClient = mock(CuratorZookeeperClient.class);
when(zookeeperClient.getCurrentConnectionString()).thenReturn(ZOOKEEPER_URL);
final CuratorFramework curatorFramework = mock(CuratorFramework.class);
when(curatorFramework.getZookeeperClient()).thenReturn(zookeeperClient);
final ZooKeeperHolder zooKeeperHolder = mock(ZooKeeperHolder.class);
when(zooKeeperHolder.get()).thenReturn(curatorFramework);
final Consumer<byte[], byte[]> consumer = mock(Consumer.class);
when(consumer.partitionsFor(any())).thenReturn(new ArrayList<>());
final KafkaFactory factory = mock(KafkaFactory.class);
when(factory.getConsumer()).thenReturn(consumer);
Mockito.doReturn(kafkaHelper.createProducer()).when(factory).takeProducer();
return new KafkaTopicRepository(zooKeeperHolder, factory, nakadiSettings, kafkaSettings, zookeeperSettings, new UUIDGenerator());
}
Aggregations