Search in sources :

Example 11 with StreamFileData

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

the class CsvBalanceFileReaderTest method readInvalidWhenFileHasInvalidVersion.

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

Example 12 with StreamFileData

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

the class CsvBalanceFileReaderTest method readInvalidWhenFileHasNoHeader.

@Test
void readInvalidWhenFileHasNoHeader() throws IOException {
    List<String> lines = FileUtils.readLines(balanceFile, CsvBalanceFileReader.CHARSET);
    lines.remove(0);
    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 13 with StreamFileData

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

the class CsvBalanceFileReaderTest method supportsInvalidWhenEmpty.

@Test
void supportsInvalidWhenEmpty() {
    StreamFileData streamFileData = StreamFileData.from(balanceFile.getName(), "");
    assertThat(balanceFileReader.supports(streamFileData)).isFalse();
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 14 with StreamFileData

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

the class CsvBalanceFileReaderTest method supports.

@Test
void supports() {
    StreamFileData streamFileData = StreamFileData.from(balanceFile);
    assertThat(balanceFileReader.supports(streamFileData)).isTrue();
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 15 with StreamFileData

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

the class ProtoBalanceFileReaderTest method missingTimestamp.

@Test
void missingTimestamp() {
    AllAccountBalances allAccountBalances = AllAccountBalances.newBuilder().addAllAccounts(SingleAccountBalances.newBuilder().build()).build();
    byte[] bytes = allAccountBalances.toByteArray();
    StreamFileData streamFileData = StreamFileData.from(TIMESTAMP + "_Balances.pb", bytes);
    assertThrows(InvalidStreamFileException.class, () -> protoBalanceFileReader.read(streamFileData));
}
Also used : AllAccountBalances(com.hedera.services.stream.proto.AllAccountBalances) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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