use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class BatchEntityListenerTest method onTopicMessage.
@Test
void onTopicMessage() throws InterruptedException {
// given
TopicMessage topicMessage1 = topicMessage();
TopicMessage topicMessage2 = topicMessage();
Flux<TopicMessage> topicMessages = subscribe(topicMessage1.getTopicId().getId());
// when
entityListener.onTopicMessage(topicMessage1);
entityListener.onTopicMessage(topicMessage2);
entityListener.onSave(new EntityBatchSaveEvent(this));
entityListener.onCleanup(new EntityBatchCleanupEvent(this));
// then
topicMessages.as(StepVerifier::create).expectNext(topicMessage1, topicMessage2).thenCancel().verify(Duration.ofMillis(1000));
}
use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class BatchEntityListenerTest method onCleanup.
@Test
void onCleanup() throws InterruptedException {
// given
TopicMessage topicMessage = topicMessage();
Flux<TopicMessage> topicMessages = subscribe(topicMessage.getTopicId().getId());
// when
entityListener.onTopicMessage(topicMessage);
entityListener.onCleanup(new EntityBatchCleanupEvent(this));
entityListener.onSave(new EntityBatchSaveEvent(this));
// then
topicMessages.as(StepVerifier::create).expectNextCount(0L).thenCancel().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class RedisEntityListenerTest method onDuplicateTopicMessages.
@Test
void onDuplicateTopicMessages() throws InterruptedException {
TopicMessage topicMessage1 = topicMessage();
TopicMessage topicMessage2 = topicMessage();
TopicMessage topicMessage3 = topicMessage();
// submitAndSave two messages, verify publish logic called twice
submitAndSave(topicMessage1);
submitAndSave(topicMessage2);
verify(redisOperations, timeout(TIMEOUT.toMillis()).times(2)).executePipelined(any(SessionCallback.class));
// submitAndSave two duplicate messages, verify publish was not attempted
Mockito.reset(redisOperations);
submitAndSave(topicMessage1);
submitAndSave(topicMessage2);
verify(redisOperations, timeout(TIMEOUT.toMillis()).times(0)).executePipelined(any(SessionCallback.class));
// submitAndSave third new unique message, verify publish called once.
Mockito.reset(redisOperations);
submitAndSave(topicMessage3);
entityListener.onCleanup(new EntityBatchCleanupEvent(this));
verify(redisOperations, timeout(TIMEOUT.toMillis()).times(1)).executePipelined(any(SessionCallback.class));
}
use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onTopicMessage.
@Test
void onTopicMessage() {
// given
TopicMessage topicMessage = domainBuilder.topicMessage().get();
// when
sqlEntityListener.onTopicMessage(topicMessage);
completeFileAndCommit();
// then
assertThat(topicMessageRepository.findAll()).containsExactlyInAnyOrder(topicMessage);
}
Aggregations