TransactionBuilder { public TransactionBuilder doIfSenderCannotCoverFees( BiConsumer<BigInteger, BigInteger> consumer) { if (supplier != null) { throw new IllegalStateException( "Can't handle a consumer for this case, since an exception " + "will be thrown if the sender cannot cover the fees."); } this.consumer = consumer; return this; } protected  TransactionBuilder(Neow3j neow); TransactionBuilder wallet(Wallet wallet); TransactionBuilder version(byte version); TransactionBuilder nonce(Long nonce); TransactionBuilder validUntilBlock(long blockNr); TransactionBuilder firstSigner(ScriptHash sender); TransactionBuilder signers(Signer... signers); TransactionBuilder additionalNetworkFee(Long fee); TransactionBuilder script(byte[] script); TransactionBuilder attributes(TransactionAttribute... attributes); NeoInvokeScript callInvokeScript(); Transaction sign(); Transaction getUnsignedTransaction(); TransactionBuilder doIfSenderCannotCoverFees(
            BiConsumer<BigInteger, BigInteger> consumer); TransactionBuilder throwIfSenderCannotCoverFees(
            Supplier<? extends Throwable> exceptionSupplier);  }
@Test public void doIfSenderCannotCoverFees() throws Throwable { setUpWireMockForCall("invokescript", "invokescript_transfer_with_fixed_sysfee.json"); setUpWireMockForBalanceOf(account1.getScriptHash(), "invokefunction_balanceOf_1000000.json"); Wallet w = Wallet.withAccounts(account1); long netFee = 1247390; long sysFee = 9007990; BigInteger expectedFees = BigInteger.valueOf(netFee + sysFee); BigInteger expectedBalance = BigInteger.valueOf(1_000_000L); AtomicBoolean tested = new AtomicBoolean(false); new GasToken(neow) .invokeFunction(NEP5_TRANSFER, ContractParameter.hash160(account1.getScriptHash()), ContractParameter.hash160(recipient), ContractParameter.integer(2_000_000)) .wallet(w) .signers(Signer.feeOnly(w.getDefaultAccount().getScriptHash())) .validUntilBlock(2000000) .doIfSenderCannotCoverFees((fee, balance) -> { assertThat(fee, is(expectedFees)); assertThat(balance, is(expectedBalance)); tested.set(true); }) .buildTransaction(); assertTrue(tested.get()); }