Search in sources :

Example 6 with StreamType

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

the class MirrorDateRangePropertiesProcessorTest method startDateNotBeforeEndDate.

@ParameterizedTest(name = "startDate {0} endDate {1} database {2} violates (effective) start date <= " + "end date constraint")
@CsvSource(value = { "2020-08-18T09:00:05.124Z, 2020-08-18T09:00:05.123Z,", "2020-08-18T09:00:04.123Z, 2020-08-18T09:00:05.123Z, 2020-08-18T09:00:05.124Z", "2020-08-18T09:00:04.123Z, 2020-08-18T09:00:05.123Z, 2020-08-18T09:00:06.123Z", ", 2020-08-18T09:00:05.123Z, 2020-08-19T09:00:05.111Z", ", 2020-08-18T09:00:05.123Z," })
void startDateNotBeforeEndDate(Instant startDate, Instant endDate, Instant lastFileDate) {
    mirrorProperties.setStartDate(startDate);
    mirrorProperties.setEndDate(endDate);
    if (lastFileDate != null) {
        doReturn(streamFile(StreamType.BALANCE, lastFileDate)).when(accountBalanceFileRepository).findLatest();
        doReturn(streamFile(StreamType.EVENT, lastFileDate)).when(eventFileRepository).findLatest();
        doReturn(streamFile(StreamType.RECORD, lastFileDate)).when(recordFileRepository).findLatest();
    }
    for (var downloaderProperties : downloaderPropertiesList) {
        StreamType streamType = downloaderProperties.getStreamType();
        assertThatThrownBy(() -> mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).isInstanceOf(InvalidConfigurationException.class);
    }
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with StreamType

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

the class MirrorDateRangePropertiesProcessorTest method startDateNotSetAndEndDateAfterLongMaxAndDatabaseNotEmpty.

@Test
void startDateNotSetAndEndDateAfterLongMaxAndDatabaseNotEmpty() {
    Instant past = STARTUP_TIME.minusSeconds(100);
    mirrorProperties.setEndDate(Utility.MAX_INSTANT_LONG.plusNanos(1));
    doReturn(streamFile(StreamType.BALANCE, past)).when(accountBalanceFileRepository).findLatest();
    doReturn(streamFile(StreamType.EVENT, past)).when(eventFileRepository).findLatest();
    doReturn(streamFile(StreamType.RECORD, past)).when(recordFileRepository).findLatest();
    for (var downloaderProperties : downloaderPropertiesList) {
        StreamType streamType = downloaderProperties.getStreamType();
        assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).matches(s -> matches(s, past));
        assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(new DateRangeFilter(past, Utility.MAX_INSTANT_LONG));
    }
    assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(Instant.EPOCH);
}
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)

Example 8 with StreamType

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

the class MirrorDateRangePropertiesProcessorTest method notSetAndDemoNetworkAndDatabaseNotEmpty.

@Test
void notSetAndDemoNetworkAndDatabaseNotEmpty() {
    mirrorProperties.setNetwork(MirrorProperties.HederaNetwork.DEMO);
    Instant past = STARTUP_TIME.minusSeconds(100);
    doReturn(streamFile(StreamType.BALANCE, past)).when(accountBalanceFileRepository).findLatest();
    doReturn(streamFile(StreamType.EVENT, past)).when(eventFileRepository).findLatest();
    doReturn(streamFile(StreamType.RECORD, past)).when(recordFileRepository).findLatest();
    for (var downloaderProperties : downloaderPropertiesList) {
        StreamType streamType = downloaderProperties.getStreamType();
        assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).matches(s -> matches(s, past));
        assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(new DateRangeFilter(past, Utility.MAX_INSTANT_LONG));
    }
    assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(Instant.EPOCH);
}
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)

Example 9 with StreamType

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

the class MirrorDateRangePropertiesProcessorTest method startDateNotAfterDatabase.

@ParameterizedTest(name = "startDate {0}ns before application status, endDate")
@ValueSource(longs = { 0, 1 })
void startDateNotAfterDatabase(long nanos) {
    Instant past = STARTUP_TIME.minusSeconds(100);
    mirrorProperties.setStartDate(past.minusNanos(nanos));
    doReturn(streamFile(StreamType.BALANCE, past)).when(accountBalanceFileRepository).findLatest();
    doReturn(streamFile(StreamType.EVENT, past)).when(eventFileRepository).findLatest();
    doReturn(streamFile(StreamType.RECORD, past)).when(recordFileRepository).findLatest();
    for (var downloaderProperties : downloaderPropertiesList) {
        StreamType streamType = downloaderProperties.getStreamType();
        assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).matches(s -> matches(s, past));
        assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(new DateRangeFilter(past, null));
    }
    assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(Instant.EPOCH);
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) Instant(java.time.Instant) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with StreamType

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

the class MirrorDateRangePropertiesProcessorTest method notSetAndDatabaseNotEmpty.

@Test
void notSetAndDatabaseNotEmpty() {
    Instant past = STARTUP_TIME.minusSeconds(100);
    doReturn(streamFile(StreamType.BALANCE, past)).when(accountBalanceFileRepository).findLatest();
    doReturn(streamFile(StreamType.EVENT, past)).when(eventFileRepository).findLatest();
    doReturn(streamFile(StreamType.RECORD, past)).when(recordFileRepository).findLatest();
    for (var downloaderProperties : downloaderPropertiesList) {
        StreamType streamType = downloaderProperties.getStreamType();
        assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).matches(s -> matches(s, past));
        assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(new DateRangeFilter(past, Utility.MAX_INSTANT_LONG));
    }
    assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(Instant.EPOCH);
}
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