Search in sources :

Example 51 with TopicMessageFilter

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

the class AbstractTopicListenerTest method startTimeAfter.

@Test
void startTimeAfter() {
    Mono<TopicMessage> topicMessage = domainBuilder.topicMessage(t -> t.consensusTimestamp(future.minusNanos(1)));
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(future).topicId(topicId).build();
    topicListener.listen(filter).as(StepVerifier::create).thenAwait(Duration.ofMillis(100)).then(() -> publish(topicMessage)).expectNextCount(0).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 52 with TopicMessageFilter

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

the class AbstractTopicListenerTest method greaterThanPageSize.

@Test
void greaterThanPageSize() {
    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(3, future))).expectNext(1L, 2L, 3L).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 53 with TopicMessageFilter

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

the class NotifyingTopicListenerTest method json.

// Test deserialization from JSON to verify contract with PostgreSQL listen/notify
@Test
void json() {
    String json = "{" + "\"@type\":\"TopicMessage\"," + "\"chunk_num\":1," + "\"chunk_total\":2," + "\"consensus_timestamp\":1594401417000000000," + "\"message\":\"AQID\"," + "\"payer_account_id\":4294968296," + "\"running_hash\":\"BAUG\"," + "\"running_hash_version\":2," + "\"sequence_number\":1," + "\"topic_id\":1001," + "\"valid_start_timestamp\":1594401416000000000" + "}";
    TopicMessage topicMessage = TopicMessage.builder().chunkNum(1).chunkTotal(2).consensusTimestamp(Instant.ofEpochSecond(1594401417)).message(new byte[] { 1, 2, 3 }).payerAccountId(4294968296L).runningHash(new byte[] { 4, 5, 6 }).runningHashVersion(2).sequenceNumber(1L).topicId(1001).validStartTimestamp(Instant.ofEpochSecond(1594401416)).build();
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(1001L, EntityType.TOPIC)).build();
    topicListener.listen(filter).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).then(() -> jdbcTemplate.execute("NOTIFY topic_message, '" + json + "'")).expectNext(topicMessage).thenCancel().verify(Duration.ofMillis(500L));
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) Test(org.junit.jupiter.api.Test)

Example 54 with TopicMessageFilter

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

the class TopicMessageRepositoryTest method findByFilterWithTopicId.

@Test
void findByFilterWithTopicId() {
    TopicMessage topicMessage1 = domainBuilder.topicMessage(t -> t.topicId(1)).block();
    TopicMessage topicMessage2 = domainBuilder.topicMessage(t -> t.topicId(2)).block();
    TopicMessage topicMessage3 = domainBuilder.topicMessage(t -> t.topicId(3)).block();
    TopicMessageFilter filter = TopicMessageFilter.builder().topicId(EntityId.of(2L, EntityType.TOPIC)).startTime(topicMessage1.getConsensusTimestampInstant()).build();
    assertThat(topicMessageRepository.findByFilter(filter)).containsExactly(topicMessage2);
}
Also used : TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Autowired(org.springframework.beans.factory.annotation.Autowired) PageRequest(org.springframework.data.domain.PageRequest) Instant(java.time.Instant) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Test(org.junit.jupiter.api.Test) Pageable(org.springframework.data.domain.Pageable) 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 55 with TopicMessageFilter

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

the class TopicMessageRepositoryTest method findByFilterWithStartTime.

@Test
void findByFilterWithStartTime() {
    TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(topicMessage2.getConsensusTimestampInstant()).topicId(EntityId.of(topicMessage1.getTopicId(), EntityType.TOPIC)).build();
    assertThat(topicMessageRepository.findByFilter(filter)).containsExactly(topicMessage2, topicMessage3);
}
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

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