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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations