TransactionTemplate extends AbstractTemplate implements TransactionOperation { @Override public TxHash sendTx(final Signer signer, final AccountAddress recipient, final Aer amount, final long nonce, final Fee fee, final BytesValue payload) { return request(transactionMethods.getSendTxByAddress(), Arrays.asList(signer, recipient, amount, nonce, fee, payload)); } TransactionTemplate(final ContextStorage<Context> contextStorage); @Override Transaction getTransaction(final TxHash txHash); @Override TxReceipt getTxReceipt(TxHash txHash); @Override TxHash commit(final Transaction transaction); @Override TxHash sendTx(final Signer signer, final AccountAddress recipient, final Aer amount,
      final long nonce, final Fee fee, final BytesValue payload); @Override TxHash sendTx(final Signer signer, final Name recipient, final Aer amount,
      final long nonce, final Fee fee, final BytesValue payload);  }
@Test public void testSendTxByAddress() throws Exception { final TransactionTemplate transactionTemplate = new TransactionTemplate(contextStorage); final Requester mockRequester = mock(Requester.class); final TxHash expected = TxHash.of(BytesValue.EMPTY); when(mockRequester.request(ArgumentMatchers.<Invocation<?>>any())) .thenReturn(expected); transactionTemplate.requester = mockRequester; final TxHash actual = transactionTemplate .sendTx(anySigner, anyAccountAddress, anyAmount, anyNonce, anyFee, anyPayload); assertEquals(expected, actual); }
@Test public void testSendTxByName() throws Exception { final TransactionTemplate transactionTemplate = new TransactionTemplate(contextStorage); final Requester mockRequester = mock(Requester.class); final TxHash expected = TxHash.of(BytesValue.EMPTY); when(mockRequester.request(ArgumentMatchers.<Invocation<?>>any())) .thenReturn(expected); transactionTemplate.requester = mockRequester; final TxHash actual = transactionTemplate .sendTx(anySigner, anyName, anyAmount, anyNonce, anyFee, anyPayload); assertEquals(expected, actual); }