Search in sources :

Example 6 with TopicMessageFilter

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

the class TopicMessageServiceTest method missingMessagesFromListenerSomeRetrieved.

@Test
void missingMessagesFromListenerSomeRetrieved() {
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(topicId).build();
    missingMessagesFromListenerTest(filter, Flux.just(topicMessage(5), topicMessage(6)));
    topicMessageService.subscribeTopic(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L, 2L, 3L, 4L, 5L, 6L).expectError(IllegalStateException.class).verify(Duration.ofMillis(700));
}
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 7 with TopicMessageFilter

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

the class TopicMessageServiceTest method startTimeAfterNow.

@Test
void startTimeAfterNow() {
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.now().plusSeconds(10L)).topicId(topicId).build();
    assertThatThrownBy(() -> topicMessageService.subscribeTopic(filter)).isInstanceOf(ConstraintViolationException.class).hasMessageContaining("Start time must be before the current time");
}
Also used : ConstraintViolationException(javax.validation.ConstraintViolationException) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 8 with TopicMessageFilter

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

the class TopicMessageServiceTest method bothMessages.

@Test
void bothMessages() {
    domainBuilder.topicMessages(3, now).blockLast();
    TopicMessageFilter filter = TopicMessageFilter.builder().limit(5).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, 4L, 5L).expectComplete().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 9 with TopicMessageFilter

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

the class TopicMessageServiceTest method noMessagesWithPastEndTime.

@Test
void noMessagesWithPastEndTime() {
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).endTime(Instant.EPOCH.plusSeconds(1)).topicId(topicId).build();
    topicMessageService.subscribeTopic(filter).as(StepVerifier::create).expectNextCount(0L).expectComplete().verify(Duration.ofMillis(500));
}
Also used : TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 10 with TopicMessageFilter

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

the class TopicMessageServiceTest method invalidTopic.

@Test
void invalidTopic() {
    domainBuilder.entity(e -> e.type(EntityType.ACCOUNT).num(100L).id(100L)).block();
    TopicMessageFilter filter = TopicMessageFilter.builder().topicId(topicId).build();
    topicMessageService.subscribeTopic(filter).as(StepVerifier::create).expectError(IllegalArgumentException.class).verify(Duration.ofMillis(100));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ArgumentMatchers(org.mockito.ArgumentMatchers) StepVerifier(reactor.test.StepVerifier) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityType(com.hedera.mirror.common.domain.entity.EntityType) EntityRepository(com.hedera.mirror.grpc.repository.EntityRepository) EntityNotFoundException(com.hedera.mirror.grpc.exception.EntityNotFoundException) TopicMessageRetriever(com.hedera.mirror.grpc.retriever.TopicMessageRetriever) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Duration(java.time.Duration) TopicListener(com.hedera.mirror.grpc.listener.TopicListener) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcProperties(com.hedera.mirror.grpc.GrpcProperties) Resource(javax.annotation.Resource) ListenerProperties(com.hedera.mirror.grpc.listener.ListenerProperties) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) Flux(reactor.core.publisher.Flux) AfterEach(org.junit.jupiter.api.AfterEach) RetrieverProperties(com.hedera.mirror.grpc.retriever.RetrieverProperties) ChronoUnit(java.time.temporal.ChronoUnit) ConstraintViolationException(javax.validation.ConstraintViolationException) Entity(com.hedera.mirror.grpc.domain.Entity) Optional(java.util.Optional) TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) DomainBuilder(com.hedera.mirror.grpc.domain.DomainBuilder) StepVerifier(reactor.test.StepVerifier) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

TopicMessageFilter (com.hedera.mirror.grpc.domain.TopicMessageFilter)62 TopicMessage (com.hedera.mirror.grpc.domain.TopicMessage)52 Test (org.junit.jupiter.api.Test)50 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)47 Instant (java.time.Instant)18 StepVerifier (reactor.test.StepVerifier)15 Duration (java.time.Duration)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 EntityId (com.hedera.mirror.common.domain.entity.EntityId)11 EntityType (com.hedera.mirror.common.domain.entity.EntityType)11 DomainBuilder (com.hedera.mirror.grpc.domain.DomainBuilder)11 Resource (javax.annotation.Resource)11 ValueSource (org.junit.jupiter.params.provider.ValueSource)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 Flux (reactor.core.publisher.Flux)11 AfterEach (org.junit.jupiter.api.AfterEach)10 BeforeEach (org.junit.jupiter.api.BeforeEach)10 ConstraintViolationException (javax.validation.ConstraintViolationException)9 GrpcProperties (com.hedera.mirror.grpc.GrpcProperties)6 EntityNotFoundException (com.hedera.mirror.grpc.exception.EntityNotFoundException)6