Search in sources :

Example 1 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class BalanceFileReaderImplV1Test method readValidFileWithLeadingEmptyLine.

@Test
void readValidFileWithLeadingEmptyLine() throws IOException {
    List<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    List<String> copy = new LinkedList<>();
    copy.add("");
    copy.addAll(lines);
    FileUtils.writeLines(testFile, copy);
    StreamFileData streamFileData = StreamFileData.from(testFile);
    AccountBalanceFile accountBalanceFile = balanceFileReader.read(streamFileData);
    assertAccountBalanceFile(accountBalanceFile);
    verifySuccess(testFile, accountBalanceFile, 2);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Example 2 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class BalanceFileReaderImplV1Test method supportsInvalidWhenWrongVersion.

@Test
void supportsInvalidWhenWrongVersion() {
    StreamFileData streamFileData = StreamFileData.from(balanceFile.getName(), BalanceFileReaderImplV2.VERSION_HEADER);
    assertThat(balanceFileReader.supports(streamFileData)).isFalse();
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 3 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class BalanceFileReaderImplV2Test method supportsInvalidWhenWrongVersion.

@Test
void supportsInvalidWhenWrongVersion() {
    StreamFileData streamFileData = StreamFileData.from(balanceFile.getName(), BalanceFileReaderImplV1.TIMESTAMP_HEADER_PREFIX);
    assertThat(balanceFileReader.supports(streamFileData)).isFalse();
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 4 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class CompositeBalanceFileReaderTest method defaultsToVersion1Reader.

@Test
void defaultsToVersion1Reader() {
    StreamFileData streamFileData = StreamFileData.from(BALANCE_FILENAME_PREFIX + ".csv", "timestamp:1");
    configMockReader(protoBalanceFileReader, streamFileData, false);
    configMockReader(readerImplV1, streamFileData, true);
    compositeBalanceFileReader.read(streamFileData);
    verify(readerImplV1, times(1)).read(streamFileData);
    verify(readerImplV2, never()).read(streamFileData);
    verify(protoBalanceFileReader, never()).read(streamFileData);
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 5 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class CsvBalanceFileReaderTest method supportsInvalidWhenInvalidFirstLine.

@Test
void supportsInvalidWhenInvalidFirstLine() {
    StreamFileData streamFileData = StreamFileData.from(balanceFile.getName(), "junk");
    assertThat(balanceFileReader.supports(streamFileData)).isFalse();
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Aggregations

StreamFileData (com.hedera.mirror.importer.domain.StreamFileData)51 Test (org.junit.jupiter.api.Test)40 AccountBalanceFile (com.hedera.mirror.common.domain.balance.AccountBalanceFile)8 Path (java.nio.file.Path)6 TestFactory (org.junit.jupiter.api.TestFactory)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 FileStreamSignature (com.hedera.mirror.importer.domain.FileStreamSignature)4 AllAccountBalances (com.hedera.services.stream.proto.AllAccountBalances)4 UnknownFieldSet (com.google.protobuf.UnknownFieldSet)3 RecordFile (com.hedera.mirror.common.domain.transaction.RecordFile)3 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)3 InvalidStreamFileException (com.hedera.mirror.importer.exception.InvalidStreamFileException)3 Instant (java.time.Instant)3 ValueSource (org.junit.jupiter.params.provider.ValueSource)3 AccountBalance (com.hedera.mirror.common.domain.balance.AccountBalance)2 TokenBalance (com.hedera.mirror.common.domain.balance.TokenBalance)2 EntityId (com.hedera.mirror.common.domain.entity.EntityId)2 EventFile (com.hedera.mirror.common.domain.event.EventFile)2 DomainUtils (com.hedera.mirror.common.util.DomainUtils)2 StreamFilename (com.hedera.mirror.importer.domain.StreamFilename)2