use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method topicNotFound.
@Test
void topicNotFound() {
TopicMessageFilter filter = TopicMessageFilter.builder().topicId(EntityId.of(999L, EntityType.TOPIC)).build();
topicMessageService.subscribeTopic(filter).as(StepVerifier::create).expectError(EntityNotFoundException.class).verify(Duration.ofMillis(100));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method invalidFilter.
@Test
void invalidFilter() {
TopicMessageFilter filter = TopicMessageFilter.builder().topicId(null).startTime(null).limit(-1).build();
assertThatThrownBy(() -> topicMessageService.subscribeTopic(filter)).isInstanceOf(ConstraintViolationException.class).hasMessageContaining("limit: must be greater than or equal to 0").hasMessageContaining("startTime: must not be null").hasMessageContaining("topicId: must not be null");
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method historicalMessagesWithEndTimeExceedsPageSize.
@Test
void historicalMessagesWithEndTimeExceedsPageSize() {
int oldMaxPageSize = retrieverProperties.getMaxPageSize();
retrieverProperties.setMaxPageSize(1);
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
TopicMessage topicMessage4 = domainBuilder.topicMessage().block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).endTime(topicMessage4.getConsensusTimestampInstant()).topicId(topicId).build();
topicMessageService.subscribeTopic(filter).as(StepVerifier::create).expectNext(topicMessage1).expectNext(topicMessage2).expectNext(topicMessage3).expectComplete().verify(Duration.ofMillis(500));
retrieverProperties.setMaxPageSize(oldMaxPageSize);
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method incomingMessages.
@Test
void incomingMessages() {
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(topicId).build();
topicMessageService.subscribeTopic(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(100)).then(() -> domainBuilder.topicMessages(3, future).blockLast()).expectNext(1L, 2L, 3L).thenCancel().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method bothMessagesWithTopicId.
@Test
void bothMessagesWithTopicId() {
domainBuilder.entity(e -> e.num(1L).id(1L)).block();
domainBuilder.entity(e -> e.num(2L).id(2L)).block();
domainBuilder.topicMessage(t -> t.topicId(0).sequenceNumber(1)).block();
domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(1)).block();
Flux<TopicMessage> generator = Flux.concat(domainBuilder.topicMessage(t -> t.topicId(0).sequenceNumber(2).consensusTimestamp(future.plusNanos(1))), domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(2).consensusTimestamp(future.plusNanos(2))), domainBuilder.topicMessage(t -> t.topicId(2).sequenceNumber(1).consensusTimestamp(future.plusNanos(3))));
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(1L, EntityType.TOPIC)).build();
topicMessageService.subscribeTopic(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(100)).then(generator::blockLast).expectNext(1L, 2L).thenCancel().verify(Duration.ofMillis(500));
}
Aggregations