Search in sources :

Example 1 with CommonParserProperties

use of com.hedera.mirror.importer.parser.CommonParserProperties in project hedera-mirror-node by hashgraph.

the class BatchInserterTest method throwsParserException.

@Test
void throwsParserException() throws SQLException, IOException {
    // given
    CopyManager copyManager = mock(CopyManager.class);
    doThrow(SQLException.class).when(copyManager).copyIn(any(), (Reader) any(), anyInt());
    PGConnection pgConnection = mock(PGConnection.class);
    doReturn(copyManager).when(pgConnection).getCopyAPI();
    DataSource dataSource = mock(DataSource.class);
    Connection conn = mock(Connection.class);
    doReturn(conn).when(dataSource).getConnection();
    doReturn(pgConnection).when(conn).unwrap(any());
    var cryptoTransferBatchInserter2 = new BatchInserter(CryptoTransfer.class, dataSource, new SimpleMeterRegistry(), new CommonParserProperties());
    var cryptoTransfers = new HashSet<CryptoTransfer>();
    cryptoTransfers.add(cryptoTransfer(1));
    // when
    assertThatThrownBy(() -> cryptoTransferBatchInserter2.persist(cryptoTransfers)).isInstanceOf(ParserException.class);
}
Also used : PGConnection(org.postgresql.PGConnection) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) CommonParserProperties(com.hedera.mirror.importer.parser.CommonParserProperties) Connection(java.sql.Connection) PGConnection(org.postgresql.PGConnection) CopyManager(org.postgresql.copy.CopyManager) DataSource(javax.sql.DataSource) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 2 with CommonParserProperties

use of com.hedera.mirror.importer.parser.CommonParserProperties in project hedera-mirror-node by hashgraph.

the class TransactionSignatureTest method setup.

@BeforeEach
void setup() {
    CommonParserProperties commonParserProperties = new CommonParserProperties();
    EntityProperties entityProperties = new EntityProperties();
    RecordParserProperties parserProperties = new RecordParserProperties();
    entityRecordItemListener = new EntityRecordItemListener(commonParserProperties, entityProperties, addressBookService, nonFeeTransferExtractionStrategy, entityIdService, entityListener, transactionHandlerFactory, fileDataRepository, parserProperties, contractResultService);
    defaultSignatureMap = getDefaultSignatureMap();
    defaultTransactionSignatures = defaultSignatureMap.getSigPairList().stream().map(pair -> {
        TransactionSignature transactionSignature = new TransactionSignature();
        transactionSignature.setConsensusTimestamp(CONSENSUS_TIMESTAMP);
        transactionSignature.setEntityId(ENTITY_ID);
        transactionSignature.setPublicKeyPrefix(pair.getPubKeyPrefix().toByteArray());
        transactionSignature.setSignature(pair.getEd25519().toByteArray());
        transactionSignature.setType(SignaturePair.SignatureCase.ED25519.getNumber());
        return transactionSignature;
    }).collect(Collectors.toList());
    transactionSignatures = entityProperties.getPersist().getTransactionSignatures();
    doReturn(ENTITY_ID).when(transactionHandler).getEntity(any(RecordItem.class));
    doReturn(transactionHandler).when(transactionHandlerFactory).get(any(TransactionType.class));
}
Also used : TransactionType(com.hedera.mirror.common.domain.transaction.TransactionType) CommonParserProperties(com.hedera.mirror.importer.parser.CommonParserProperties) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionSignature(com.hedera.mirror.common.domain.transaction.TransactionSignature) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CommonParserProperties (com.hedera.mirror.importer.parser.CommonParserProperties)2 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)1 TransactionSignature (com.hedera.mirror.common.domain.transaction.TransactionSignature)1 TransactionType (com.hedera.mirror.common.domain.transaction.TransactionType)1 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)1 RecordParserProperties (com.hedera.mirror.importer.parser.record.RecordParserProperties)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 Connection (java.sql.Connection)1 HashSet (java.util.HashSet)1 DataSource (javax.sql.DataSource)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 PGConnection (org.postgresql.PGConnection)1 CopyManager (org.postgresql.copy.CopyManager)1