Search in sources :

Example 21 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class AbstractTopicListenerTest method startTimeEquals.

@Test
void startTimeEquals() {
    Mono<TopicMessage> topicMessage = domainBuilder.topicMessage(t -> t.consensusTimestamp(future));
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(future).topicId(topicId).build();
    topicListener.listen(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).then(() -> publish(topicMessage)).expectNext(1L).thenCancel().verify(Duration.ofMillis(500));
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 22 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class AbstractTopicListenerTest method equalPageSize.

@Test
void equalPageSize() {
    int maxPageSize = listenerProperties.getMaxPageSize();
    listenerProperties.setMaxPageSize(2);
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(topicId).build();
    topicListener.listen(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).then(() -> publish(domainBuilder.topicMessages(2, future))).expectNext(1L, 2L).thenCancel().verify(Duration.ofMillis(500));
    listenerProperties.setMaxPageSize(maxPageSize);
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 23 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class AbstractTopicListenerTest method topicId.

@Test
void topicId() {
    Flux<TopicMessage> generator = Flux.concat(domainBuilder.topicMessage(t -> t.topicId(0).consensusTimestamp(future.plusNanos(1L))), domainBuilder.topicMessage(t -> t.topicId(1).consensusTimestamp(future.plusNanos(2L))), domainBuilder.topicMessage(t -> t.topicId(2).consensusTimestamp(future.plusNanos(3L))));
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(1L, EntityType.TOPIC)).build();
    topicListener.listen(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).then(() -> publish(generator)).expectNext(2L).thenCancel().verify(Duration.ofMillis(500));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) StepVerifier(reactor.test.StepVerifier) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Publisher(org.reactivestreams.Publisher) Resource(javax.annotation.Resource) Autowired(org.springframework.beans.factory.annotation.Autowired) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) EntityType(com.hedera.mirror.common.domain.entity.EntityType) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) AfterEach(org.junit.jupiter.api.AfterEach) Duration(java.time.Duration) TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) DomainBuilder(com.hedera.mirror.grpc.domain.DomainBuilder) TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 24 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class TopicMessageRepositoryTest method findByFilterWithLimit.

@Test
void findByFilterWithLimit() {
    TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
    TopicMessageFilter filter = TopicMessageFilter.builder().limit(1).startTime(topicMessage1.getConsensusTimestampInstant()).topicId(EntityId.of(topicMessage1.getTopicId(), EntityType.TOPIC)).build();
    assertThat(topicMessageRepository.findByFilter(filter)).containsExactly(topicMessage1);
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 25 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class TopicMessageRepositoryTest method findByFilterNoMatch.

@Test
void findByFilterNoMatch() {
    TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.now().plusSeconds(10)).topicId(EntityId.of(topicMessage1.getTopicId(), EntityType.TOPIC)).build();
    assertThat(topicMessageRepository.findByFilter(filter)).isEmpty();
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

TopicMessage (com.hedera.mirror.grpc.domain.TopicMessage)58 TopicMessageFilter (com.hedera.mirror.grpc.domain.TopicMessageFilter)50 Test (org.junit.jupiter.api.Test)45 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)43 Instant (java.time.Instant)17 StepVerifier (reactor.test.StepVerifier)15 Duration (java.time.Duration)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 DomainBuilder (com.hedera.mirror.grpc.domain.DomainBuilder)10 Resource (javax.annotation.Resource)10 ValueSource (org.junit.jupiter.params.provider.ValueSource)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 Flux (reactor.core.publisher.Flux)10 EntityId (com.hedera.mirror.common.domain.entity.EntityId)9 EntityType (com.hedera.mirror.common.domain.entity.EntityType)9 AfterEach (org.junit.jupiter.api.AfterEach)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ConsensusTopicQuery (com.hedera.mirror.api.proto.ConsensusTopicQuery)6 GrpcProperties (com.hedera.mirror.grpc.GrpcProperties)5 ListenerProperties (com.hedera.mirror.grpc.listener.ListenerProperties)5