Search in sources :

Example 31 with StreamFileData

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

the class CsvBalanceFileReaderTest method readInvalidWhenFileHasNoColumnHeader.

@Test
void readInvalidWhenFileHasNoColumnHeader() throws IOException {
    Collection<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    Collection<String> filtered = Collections2.filter(lines, line -> !line.contains(CsvBalanceFileReader.COLUMN_HEADER_PREFIX));
    FileUtils.writeLines(testFile, filtered);
    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 32 with StreamFileData

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

the class CsvBalanceFileReaderTest method readInvalidWhenFileHasMalformedTimestamp.

@Test
void readInvalidWhenFileHasMalformedTimestamp() throws IOException {
    String prefix = balanceFileReader.getTimestampHeaderPrefix();
    Collection<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    Collection<String> filtered = Collections2.transform(lines, line -> StringUtils.startsWithIgnoreCase(line, prefix) ? prefix : line);
    FileUtils.writeLines(testFile, filtered);
    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 33 with StreamFileData

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

the class CsvBalanceFileReaderTest method supportsInvalidWhenWrongExtension.

@Test
void supportsInvalidWhenWrongExtension() {
    StreamFileData streamFileData = StreamFileData.from("2021-03-10T16:00:00Z_Balances.csv", "");
    assertThat(balanceFileReader.supports(streamFileData)).isFalse();
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 34 with StreamFileData

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

the class CsvBalanceFileReaderTest method readInvalidWhenFileDoesNotExist.

@Test
void readInvalidWhenFileDoesNotExist() {
    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 35 with StreamFileData

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

the class CsvBalanceFileReaderTest method readValidWhenFileHasTrailingEmptyLines.

@Test
void readValidWhenFileHasTrailingEmptyLines() throws IOException {
    List<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    FileUtils.writeLines(testFile, lines);
    FileUtils.writeStringToFile(testFile, "\n\n\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)

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