Search in sources :

Example 1 with AccountBalanceFile

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);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) Test(org.junit.jupiter.api.Test)

Example 2 with AccountBalanceFile

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);
}
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 3 with AccountBalanceFile

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);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 4 with AccountBalanceFile

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);
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 5 with AccountBalanceFile

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);
    }
}
Also used : AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) Stopwatch(com.google.common.base.Stopwatch)

Aggregations

AccountBalanceFile (com.hedera.mirror.common.domain.balance.AccountBalanceFile)23 Test (org.junit.jupiter.api.Test)18 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)9 AccountBalance (com.hedera.mirror.common.domain.balance.AccountBalance)8 StreamFileData (com.hedera.mirror.importer.domain.StreamFileData)7 Instant (java.time.Instant)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 UnknownFieldSet (com.google.protobuf.UnknownFieldSet)2 TokenBalance (com.hedera.mirror.common.domain.balance.TokenBalance)2 EntityId (com.hedera.mirror.common.domain.entity.EntityId)2 AllAccountBalances (com.hedera.services.stream.proto.AllAccountBalances)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Stopwatch (com.google.common.base.Stopwatch)1 CodedInputStream (com.google.protobuf.CodedInputStream)1 StreamType (com.hedera.mirror.common.domain.StreamType)1 EntityType (com.hedera.mirror.common.domain.entity.EntityType)1 DomainUtils (com.hedera.mirror.common.util.DomainUtils)1