BTCTradeAdapters { public static Wallet adaptWallet(BTCTradeBalance balance) { checkException(balance); List<Balance> balances = new ArrayList<>(5); balances.add( new Balance( Currency.BTC, nullSafeSum(balance.getBtcBalance(), balance.getBtcReserved()), zeroIfNull(balance.getBtcBalance()), zeroIfNull(balance.getBtcReserved()))); balances.add( new Balance( Currency.LTC, nullSafeSum(balance.getLtcBalance(), balance.getLtcReserved()), zeroIfNull(balance.getLtcBalance()), zeroIfNull(balance.getLtcReserved()))); balances.add( new Balance( Currency.DOGE, nullSafeSum(balance.getDogeBalance(), balance.getDogeReserved()), zeroIfNull(balance.getDogeBalance()), zeroIfNull(balance.getDogeReserved()))); balances.add( new Balance( Currency.YBC, nullSafeSum(balance.getYbcBalance(), balance.getYbcReserved()), zeroIfNull(balance.getYbcBalance()), zeroIfNull(balance.getYbcReserved()))); balances.add( new Balance( Currency.CNY, nullSafeSum(balance.getCnyBalance(), balance.getCnyReserved()), zeroIfNull(balance.getCnyBalance()), zeroIfNull(balance.getCnyReserved()))); return Wallet.Builder.from(balances).build(); } private  BTCTradeAdapters(); static Date adaptDatetime(String datetime); static CurrencyPair adaptCurrencyPair(String coin); static Ticker adaptTicker(BTCTradeTicker btcTradeTicker, CurrencyPair currencyPair); static OrderBook adaptOrderBook(BTCTradeDepth btcTradeDepth, CurrencyPair currencyPair); static Trades adaptTrades(BTCTradeTrade[] btcTradeTrades, CurrencyPair currencyPair); static boolean adaptResult(BTCTradeResult result); static Wallet adaptWallet(BTCTradeBalance balance); static String adaptDepositAddress(BTCTradeWallet wallet); static String adaptPlaceOrderResult(BTCTradePlaceOrderResult result); static OpenOrders adaptOpenOrders(BTCTradeOrder[] btcTradeOrders); static UserTrades adaptTrades(
      BTCTradeOrder[] btcTradeOrders, BTCTradeOrder[] btcTradeOrderDetails);  }
@Test public void testAdaptAccountInfo() throws IOException { BTCTradeBalance balance = mapper.readValue(getClass().getResource("dto/account/balance.json"), BTCTradeBalance.class); Wallet wallet = BTCTradeAdapters.adaptWallet(balance); assertNull(wallet.getId()); assertEquals(new BigDecimal(3), wallet.getBalance(Currency.BTC).getTotal()); assertEquals(new BigDecimal(2), wallet.getBalance(Currency.BTC).getFrozen()); assertEquals(new BigDecimal("7"), wallet.getBalance(Currency.LTC).getTotal()); assertEquals(new BigDecimal(4), wallet.getBalance(Currency.LTC).getFrozen()); assertEquals(new BigDecimal("11"), wallet.getBalance(Currency.DOGE).getTotal()); assertEquals(new BigDecimal(6), wallet.getBalance(Currency.DOGE).getFrozen()); assertEquals(new BigDecimal("15"), wallet.getBalance(Currency.YBC).getTotal()); assertEquals(new BigDecimal(8), wallet.getBalance(Currency.YBC).getFrozen()); assertEquals(new BigDecimal("19"), wallet.getBalance(Currency.CNY).getTotal()); assertEquals(new BigDecimal(10), wallet.getBalance(Currency.CNY).getFrozen()); }
@Test public void testAdaptAccountInfoError() throws IOException { BTCTradeBalance balance = mapper.readValue( getClass().getResource("dto/account/balance-signature-error.json"), BTCTradeBalance.class); try { BTCTradeAdapters.adaptWallet(balance); fail("ExchangeException is expected."); } catch (ExchangeException e) { assertEquals("signature error", e.getMessage()); } }