Search in sources :

Example 11 with StreamType

use of com.hedera.mirror.common.domain.StreamType in project hedera-mirror-node by hashgraph.

the class MirrorDateRangePropertiesProcessorTest method startDateAfterDatabase.

@ParameterizedTest(name = "startDate is {0}ns after application status")
@ValueSource(longs = { 1, 2_000_000_000L, 200_000_000_000L })
void startDateAfterDatabase(long diffNanos) {
    Instant lastFileInstant = Instant.now().minusSeconds(200);
    doReturn(streamFile(StreamType.BALANCE, lastFileInstant)).when(accountBalanceFileRepository).findLatest();
    doReturn(streamFile(StreamType.EVENT, lastFileInstant)).when(eventFileRepository).findLatest();
    doReturn(streamFile(StreamType.RECORD, lastFileInstant)).when(recordFileRepository).findLatest();
    Instant startDate = lastFileInstant.plusNanos(diffNanos);
    mirrorProperties.setStartDate(startDate);
    Instant effectiveStartDate = max(startDate, lastFileInstant);
    DateRangeFilter expectedFilter = new DateRangeFilter(startDate, null);
    for (var downloaderProperties : downloaderPropertiesList) {
        StreamType streamType = downloaderProperties.getStreamType();
        Optional<StreamFile> streamFile = streamFile(streamType, effectiveStartDate);
        assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).isEqualTo(streamFile);
        assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(downloaderProperties.getStreamType())).isEqualTo(expectedFilter);
    }
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) Instant(java.time.Instant) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) StreamFile(com.hedera.mirror.common.domain.StreamFile) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with StreamType

use of com.hedera.mirror.common.domain.StreamType in project hedera-mirror-node by hashgraph.

the class MirrorDateRangePropertiesProcessorTest method notSetAndDatabaseEmpty.

@Test
void notSetAndDatabaseEmpty() {
    Instant expectedDate = STARTUP_TIME;
    DateRangeFilter expectedFilter = new DateRangeFilter(expectedDate, null);
    for (var downloaderProperties : downloaderPropertiesList) {
        StreamType streamType = downloaderProperties.getStreamType();
        assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).isEqualTo(streamFile(streamType, expectedDate));
        assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(expectedFilter);
    }
    assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(expectedDate);
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) Instant(java.time.Instant) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

StreamType (com.hedera.mirror.common.domain.StreamType)12 Instant (java.time.Instant)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 DateRangeFilter (com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter)7 Test (org.junit.jupiter.api.Test)5 StreamFile (com.hedera.mirror.common.domain.StreamFile)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Named (javax.inject.Named)3 Log4j2 (lombok.extern.log4j.Log4j2)3 DomainUtils (com.hedera.mirror.common.util.DomainUtils)2 MirrorProperties (com.hedera.mirror.importer.MirrorProperties)2 StreamFilename (com.hedera.mirror.importer.domain.StreamFilename)2 DATA (com.hedera.mirror.importer.domain.StreamFilename.FileType.DATA)2 DownloaderProperties (com.hedera.mirror.importer.downloader.DownloaderProperties)2 InvalidConfigurationException (com.hedera.mirror.importer.exception.InvalidConfigurationException)2 AccountBalanceFileRepository (com.hedera.mirror.importer.repository.AccountBalanceFileRepository)2 EventFileRepository (com.hedera.mirror.importer.repository.EventFileRepository)2 RecordFileRepository (com.hedera.mirror.importer.repository.RecordFileRepository)2 StreamFileRepository (com.hedera.mirror.importer.repository.StreamFileRepository)2