BTCMarketsAccountService extends BTCMarketsAccountServiceRaw implements AccountService { @Override public String withdrawFunds(WithdrawFundsParams params) throws IOException { if (params instanceof DefaultWithdrawFundsParams) { DefaultWithdrawFundsParams defaultWithdrawFundsParams = (DefaultWithdrawFundsParams) params; String address = defaultWithdrawFundsParams.address; if (params instanceof RippleWithdrawFundsParams) { address = address + "?dt=" + ((RippleWithdrawFundsParams) params).tag; } withdrawCrypto( address, defaultWithdrawFundsParams.getAmount(), defaultWithdrawFundsParams.getCurrency()); return null; } throw new IllegalStateException("Cannot process " + params); } BTCMarketsAccountService(Exchange exchange); @Override AccountInfo getAccountInfo(); @Override String withdrawFunds(WithdrawFundsParams params); @Override TradeHistoryParams createFundingHistoryParams(); @Override List<FundingRecord> getFundingHistory(TradeHistoryParams params); @Override String requestDepositAddress(Currency currency, String... args);  }
@Test public void withdrawFundsShouldReturnNull() throws IOException { String status = "the-status"; BTCMarketsWithdrawCryptoResponse response = new BTCMarketsWithdrawCryptoResponse( true, null, null, status, "id", "desc", "ccy", BigDecimal.ONE, BigDecimal.ONE, 0L); PowerMockito.when( btcm.withdrawCrypto( Mockito.eq(SPECIFICATION_API_KEY), Mockito.any(SynchronizedValueFactory.class), Mockito.any(BTCMarketsDigest.class), Mockito.any(BTCMarketsWithdrawCryptoRequest.class))) .thenReturn(response); String result = accountService.withdrawFunds(Currency.BTC, BigDecimal.TEN, "any address"); assertThat(result).isNull(); }
@Test public void withdrawFundsShouldAppendRippleTag() throws IOException { String status = "the-status"; BTCMarketsWithdrawCryptoResponse response = new BTCMarketsWithdrawCryptoResponse( true, null, null, status, "id", "desc", "ccy", BigDecimal.ONE, BigDecimal.ONE, 0L); ArgumentCaptor<BTCMarketsWithdrawCryptoRequest> captor = ArgumentCaptor.forClass(BTCMarketsWithdrawCryptoRequest.class); PowerMockito.when( btcm.withdrawCrypto( Mockito.eq(SPECIFICATION_API_KEY), Mockito.any(SynchronizedValueFactory.class), Mockito.any(BTCMarketsDigest.class), captor.capture())) .thenReturn(response); RippleWithdrawFundsParams params = new RippleWithdrawFundsParams("any address", Currency.BTC, BigDecimal.TEN, "12345"); String result = accountService.withdrawFunds(params); assertThat(captor.getValue().address).isEqualTo("any address?dt=12345"); assertThat(result).isNull(); }