Search in sources :

Example 1 with NakadiKafkaConsumer

use of org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer in project nakadi by zalando.

the class EventStreamTest method emptyConsumer.

private static NakadiKafkaConsumer emptyConsumer() throws NakadiException {
    final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class);
    when(nakadiKafkaConsumer.readEvents()).thenReturn(Collections.emptyList());
    return nakadiKafkaConsumer;
}
Also used : NakadiKafkaConsumer(org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer)

Example 2 with NakadiKafkaConsumer

use of org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer in project nakadi by zalando.

the class EventStreamTest method predefinedConsumer.

private static NakadiKafkaConsumer predefinedConsumer(final List<ConsumedEvent> events) throws NakadiException {
    final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class);
    final AtomicBoolean sent = new AtomicBoolean(false);
    when(nakadiKafkaConsumer.readEvents()).thenAnswer(invocation -> {
        if (sent.get()) {
            return Collections.emptyList();
        } else {
            sent.set(true);
            return events;
        }
    });
    return nakadiKafkaConsumer;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NakadiKafkaConsumer(org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer)

Example 3 with NakadiKafkaConsumer

use of org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer in project nakadi by zalando.

the class EventStreamTest method nCountDummyConsumerForPartition.

private static NakadiKafkaConsumer nCountDummyConsumerForPartition(final int eventNum, final String partition) throws NakadiException {
    final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class);
    final AtomicInteger eventsToCreate = new AtomicInteger(eventNum);
    when(nakadiKafkaConsumer.readEvents()).thenAnswer(invocation -> {
        if (eventsToCreate.get() > 0) {
            eventsToCreate.set(eventsToCreate.get() - 1);
            return Collections.singletonList(new ConsumedEvent(DUMMY, NakadiCursor.of(TIMELINE, partition, "000000000000000000")));
        } else {
            return Collections.emptyList();
        }
    });
    return nakadiKafkaConsumer;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NakadiKafkaConsumer(org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer) ConsumedEvent(org.zalando.nakadi.domain.ConsumedEvent)

Example 4 with NakadiKafkaConsumer

use of org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer in project nakadi by zalando.

the class EventStreamTest method endlessDummyConsumerForPartition.

private static NakadiKafkaConsumer endlessDummyConsumerForPartition(final String partition) throws NakadiException {
    final NakadiKafkaConsumer nakadiKafkaConsumer = mock(NakadiKafkaConsumer.class);
    when(nakadiKafkaConsumer.readEvents()).thenReturn(Collections.singletonList(new ConsumedEvent(DUMMY, NakadiCursor.of(TIMELINE, partition, "0"))));
    return nakadiKafkaConsumer;
}
Also used : NakadiKafkaConsumer(org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer) ConsumedEvent(org.zalando.nakadi.domain.ConsumedEvent)

Aggregations

NakadiKafkaConsumer (org.zalando.nakadi.repository.kafka.NakadiKafkaConsumer)4 ConsumedEvent (org.zalando.nakadi.domain.ConsumedEvent)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1