### Question:
DexSmartContractService { public String refund(byte[] secretHash, String passphrase, String fromAddress, long accountId, boolean waitConfirmation) throws AplException.ExecutiveProcessException { EthWalletKey ethWalletKey = getEthWalletKey(passphrase, accountId, fromAddress); String params = Numeric.toHexString(secretHash); String identifier = fromAddress + params + DexTransaction.Op.REFUND; synchronized (idLocks.compute(identifier, (k, v) -> v == null ? new Object() : v)) { String txHash = checkExistingTx(dexTransactionDao.get(params, fromAddress, DexTransaction.Op.REFUND), waitConfirmation); if (txHash == null) { ContractGasProvider contractGasProvider = new ComparableStaticGasProvider(EtherUtil.convert(getEthGasPrice(), EtherUtil.Unit.GWEI), Constants.GAS_LIMIT_FOR_ETH_ATOMIC_SWAP_CONTRACT); DexContract dexContract = createDexContract(contractGasProvider, createDexTransaction(DexTransaction.Op.REFUND, params, fromAddress), ethWalletKey.getCredentials()); txHash = dexContract.refund(secretHash, waitConfirmation); } locksToRemoveLater.add(identifier); return txHash; } } @Inject  DexSmartContractService(PropertiesHolder propertiesHolder, KeyStoreService keyStoreService, DexEthService dexEthService,
                                   EthereumWalletService ethereumWalletService, DexTransactionDao dexTransactionDao,
                                   DexBeanProducer dexBeanProducer, TaskDispatchManager taskDispatchManager); @PostConstruct void init(); String deposit(String passphrase, Long offerId, Long accountId, String fromAddress, BigInteger weiValue, Long gas, DexCurrency currency); String withdraw(String passphrase, long accountId, String fromAddress, BigInteger orderId, Long gas); String initiate(String passphrase, long accountId, String fromAddress, Long orderId, byte[] secretHash, String recipient, Integer refundTimestamp, Long gas); String approve(String passphrase, byte[] secret, String fromAddress, long accountId); String refund(byte[] secretHash, String passphrase, String fromAddress, long accountId, boolean waitConfirmation); String refundAndWithdraw(byte[] secretHash, String passphrase, String fromAddress, long accountId, boolean waitConfirmation); boolean hasFrozenMoney(DexOrder order); SwapDataInfo getSwapData(byte[] secretHash); SwapDataInfo getSwapData(Credentials credentials, byte[] secretHash); String getHashForAtomicSwapTransaction(long orderId); EthDepositsWithOffset getUserActiveDeposits(String user, long offset, long limit); EthDepositsWithOffset getUserFilledOrders(String user, long offset, long limit); List<ExpiredSwap> getExpiredSwaps(String user); UserAddressesWithOffset getUserAddresses(long offset, long limit); boolean isDepositForOrderExist(String userAddress, Long orderId); boolean isDepositForOrderExist(String userAddress, Long orderId, BigDecimal amountEth); List<String> getEthUserAddresses(String passphrase, Long accountId); DepositedOrderDetails getDepositedOrderDetails(String address, Long orderId);  }### Answer:
@Test void testRefund() throws ExecutionException, AplException.ExecutiveProcessException { doReturn(aliceWalletKeysInfo).when(keyStoreService).getWalletKeysInfo(ALICE_PASS, ALICE_ID); doReturn(gasInfo).when(dexEthService).getEthPriceInfo(); doReturn(dexContract).when(service).createDexContract(new ComparableStaticGasProvider(BigInteger.valueOf(100_000_000_000L), BigInteger.valueOf(400_000)), new DexTransaction(null, null, null, DexTransaction.Op.REFUND, empty32EncodedBytes, ALICE_ETH_ADDRESS, 0), aliceWalletKey.getCredentials()); doReturn("hash").when(dexContract).refundAndWithdraw(secretHash, true); boolean r = service.refundAndWithdraw(secretHash, ALICE_PASS, ALICE_ETH_ADDRESS, ALICE_ID, true) != null; assertTrue(r); }