use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.
the class AccountBalanceFileRepositoryTest method findLatest.
@Test
void findLatest() {
AccountBalanceFile accountBalanceFile1 = accountBalanceFile();
AccountBalanceFile accountBalanceFile2 = accountBalanceFile();
AccountBalanceFile accountBalanceFile3 = accountBalanceFile();
accountBalanceFileRepository.saveAll(List.of(accountBalanceFile1, accountBalanceFile2, accountBalanceFile3));
assertThat(accountBalanceFileRepository.findLatest()).get().isEqualTo(accountBalanceFile3);
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile 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);
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile 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);
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile 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);
}
use of com.hedera.mirror.common.domain.balance.AccountBalanceFile in project hedera-mirror-node by hashgraph.
the class CompositeBalanceFileReader method read.
@Override
public AccountBalanceFile read(StreamFileData streamFileData) {
Stopwatch stopwatch = Stopwatch.createStarted();
boolean success = false;
try {
BalanceFileReader balanceFileReader = getReader(streamFileData);
AccountBalanceFile accountBalanceFile = balanceFileReader.read(streamFileData);
success = true;
return accountBalanceFile;
} finally {
log.info("Read account balance file {} {}successfully in {}", streamFileData.getFilename(), success ? "" : "un", stopwatch);
}
}
Aggregations