Search in sources :

Example 6 with StreamFileData

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

the class CsvBalanceFileReaderTest method supportsInvalidWhenEmptyFirstLine.

@Test
void supportsInvalidWhenEmptyFirstLine() {
    String versionPrefix = balanceFileReader.getVersionHeaderPrefix();
    StreamFileData streamFileData = StreamFileData.from(balanceFile.getName(), '\n' + versionPrefix);
    assertThat(balanceFileReader.supports(streamFileData)).isFalse();
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 7 with StreamFileData

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

the class CsvBalanceFileReaderTest method readInvalidWhenFileHasNoTimestampHeader.

@Test
void readInvalidWhenFileHasNoTimestampHeader() throws IOException {
    List<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    lines.remove(0);
    FileUtils.writeLines(testFile, lines);
    StreamFileData streamFileData = StreamFileData.from(testFile);
    assertThrows(InvalidDatasetException.class, () -> balanceFileReader.read(streamFileData));
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 8 with StreamFileData

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

the class CsvBalanceFileReaderTest method readInvalidWhenFileIsEmpty.

@Test
void readInvalidWhenFileIsEmpty() {
    StreamFileData streamFileData = StreamFileData.from(balanceFile.getName(), "");
    assertThrows(InvalidDatasetException.class, () -> balanceFileReader.read(streamFileData));
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 9 with StreamFileData

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

the class CsvBalanceFileReaderTest method readValidWhenFileHasBadTrailingLines.

@Test
void readValidWhenFileHasBadTrailingLines() throws IOException {
    List<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    FileUtils.writeLines(testFile, lines);
    FileUtils.writeStringToFile(testFile, "\n0.0.3.20340\nfoobar\n", CsvBalanceFileReader.CHARSET, true);
    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) Test(org.junit.jupiter.api.Test)

Example 10 with StreamFileData

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

the class CsvBalanceFileReaderTest method readValid.

@Test
void readValid() throws Exception {
    StreamFileData streamFileData = StreamFileData.from(balanceFile);
    AccountBalanceFile accountBalanceFile = balanceFileReader.read(streamFileData);
    assertAccountBalanceFile(accountBalanceFile);
    assertFileHash(balanceFile, accountBalanceFile);
    verifySuccess(balanceFile, accountBalanceFile, 2);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) 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