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