Search in sources :

Example 6 with StreamFile

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

the class AbstractStreamFileParserTest method parse.

@Test
void parse() {
    // given
    StreamFile streamFile = getStreamFile();
    // when
    parser.parse(streamFile);
    // then
    assertParsed(streamFile, true, false);
    assertPostParseStreamFile(streamFile, true);
}
Also used : StreamFile(com.hedera.mirror.common.domain.StreamFile) Test(org.junit.jupiter.api.Test)

Example 7 with StreamFile

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

the class AbstractStreamFileParserTest method disabled.

@Test
void disabled() {
    // given
    parserProperties.setEnabled(false);
    StreamFile streamFile = getStreamFile();
    // when
    parser.parse(streamFile);
    // then
    assertParsed(streamFile, false, false);
    assertPostParseStreamFile(streamFile, true);
}
Also used : StreamFile(com.hedera.mirror.common.domain.StreamFile) Test(org.junit.jupiter.api.Test)

Example 8 with StreamFile

use of com.hedera.mirror.common.domain.StreamFile 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 9 with StreamFile

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

the class MirrorDateRangePropertiesProcessorTest method streamFile.

private Optional<StreamFile> streamFile(StreamType streamType, Instant instant) {
    StreamFile streamFile = (StreamFile) ReflectUtils.newInstance(streamType.getStreamFileClass());
    streamFile.setConsensusStart(DomainUtils.convertToNanosMax(instant));
    streamFile.setName(StreamFilename.getFilename(streamType, DATA, instant));
    return Optional.of(streamFile);
}
Also used : StreamFile(com.hedera.mirror.common.domain.StreamFile)

Example 10 with StreamFile

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

the class AbstractDownloaderTest method expectLastStreamFile.

/**
 * Sets the expected last stream file. If the precondition is there is no stream files in db, pass in a null index.
 *
 * @param hash    hash of the StreamFile
 * @param index   the index of the StreamFile
 * @param instant the instant of the StreamFile
 */
protected void expectLastStreamFile(String hash, Long index, Instant instant) {
    StreamFile streamFile = (StreamFile) ReflectUtils.newInstance(streamType.getStreamFileClass());
    streamFile.setName(StreamFilename.getFilename(streamType, DATA, instant));
    streamFile.setConsensusStart(DomainUtils.convertToNanosMax(instant));
    streamFile.setHash(hash);
    streamFile.setIndex(index);
    if (hash != null) {
        downloaderProperties.getMirrorProperties().setVerifyHashAfter(instant);
    }
    firstIndex = index == null ? 0L : index + 1;
    doReturn(Optional.of(streamFile)).when(dateRangeProcessor).getLastStreamFile(streamType);
}
Also used : StreamFile(com.hedera.mirror.common.domain.StreamFile)

Aggregations

StreamFile (com.hedera.mirror.common.domain.StreamFile)11 Test (org.junit.jupiter.api.Test)5 StreamType (com.hedera.mirror.common.domain.StreamType)4 Instant (java.time.Instant)4 DomainUtils (com.hedera.mirror.common.util.DomainUtils)3 MirrorProperties (com.hedera.mirror.importer.MirrorProperties)3 StreamFilename (com.hedera.mirror.importer.domain.StreamFilename)3 DATA (com.hedera.mirror.importer.domain.StreamFilename.FileType.DATA)3 Duration (java.time.Duration)3 List (java.util.List)3 Optional (java.util.Optional)3 Log4j2 (lombok.extern.log4j.Log4j2)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ReflectUtils (org.springframework.cglib.core.ReflectUtils)3 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