use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method missingMessagesFromListenerNoneRetrieved.
@Test
void missingMessagesFromListenerNoneRetrieved() {
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(topicId).build();
missingMessagesFromListenerTest(filter, Flux.empty());
topicMessageService.subscribeTopic(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L, 2L, 3L, 4L).expectError(IllegalStateException.class).verify(Duration.ofMillis(700));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method historicalMessagesWithLimit.
@Test
void historicalMessagesWithLimit() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
domainBuilder.topicMessage().block();
TopicMessageFilter filter = TopicMessageFilter.builder().limit(2).startTime(Instant.EPOCH).topicId(topicId).build();
topicMessageService.subscribeTopic(filter).as(StepVerifier::create).expectNext(topicMessage1).expectNext(topicMessage2).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method historicalMessages.
@Test
void historicalMessages() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(topicId).build();
topicMessageService.subscribeTopic(filter).as(StepVerifier::create).expectNext(topicMessage1, topicMessage2, topicMessage3).thenCancel().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method incomingMessagesWithEndTimeEquals.
@Test
void incomingMessagesWithEndTimeEquals() {
Flux<TopicMessage> generator = domainBuilder.topicMessages(3, future.minusNanos(2));
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).endTime(future).topicId(topicId).build();
topicMessageService.subscribeTopic(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(100)).then(generator::blockLast).expectNext(1L, 2L).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class AbstractTopicListenerTest method multipleSubscribers.
@Test
void multipleSubscribers() {
// @formatter:off
Flux<TopicMessage> generator = Flux.concat(domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(1).consensusTimestamp(future.plusNanos(1L))), domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(2).consensusTimestamp(future.plusNanos(2L))), domainBuilder.topicMessage(t -> t.topicId(2).sequenceNumber(7).consensusTimestamp(future.plusNanos(3L))), domainBuilder.topicMessage(t -> t.topicId(2).sequenceNumber(8).consensusTimestamp(future.plusNanos(4L))), domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(3).consensusTimestamp(future.plusNanos(5L))));
// @formatter:on
TopicMessageFilter filter1 = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(1L, EntityType.TOPIC)).build();
TopicMessageFilter filter2 = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(2L, EntityType.TOPIC)).build();
StepVerifier stepVerifier1 = topicListener.listen(filter1).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L, 2L, 3L).thenCancel().verifyLater();
StepVerifier stepVerifier2 = topicListener.listen(filter2).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(7L, 8L).thenCancel().verifyLater();
Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
publish(generator);
stepVerifier1.verify(Duration.ofMillis(500));
stepVerifier2.verify(Duration.ofMillis(500));
topicListener.listen(filter1).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).as("Verify can still re-subscribe after poller cancelled when no subscriptions").expectNextCount(0).thenCancel().verify(Duration.ofMillis(100));
}
Aggregations