use of io.divolte.server.processing.Item in project divolte-collector by divolte.
the class GoogleCloudPubSubFlusherTest method testMessageBatchSentToPublisher.
@Test
public void testMessageBatchSentToPublisher() {
final Publisher publisher = mockPublisher.orElseThrow(IllegalStateException::new);
// Process a bunch of messages.
final DivolteSchema schema = new DivolteSchema(MINIMAL_SCHEMA, Optional.empty());
final GoogleCloudPubSubFlusher flusher = new GoogleCloudPubSubFlusher(publisher, schema);
final Queue<Item<AvroRecordBuffer>> items = Stream.generate(this::generateMessage).limit(10).map(this::itemFromAvroRecordBuffer).collect(Collectors.toCollection(() -> new ArrayBlockingQueue<>(10)));
flusher.process(items);
// Check the messages were all forwarded to the publisher.
verify(publisher, times(10)).publish(any(PubsubMessage.class));
verifyNoMoreInteractions(publisher);
}
Aggregations