BitcoindeAdapters { public static AccountInfo adaptAccountInfo(BitcoindeAccountWrapper bitcoindeAccount) { final boolean hasBalances = bitcoindeAccount.getData().getBalances() != null && bitcoindeAccount.getData().getBalances().size() > 0; final boolean hasAllocations = bitcoindeAccount.getData().getFidorReservation() != null && bitcoindeAccount.getData().getFidorReservation().getAllocation() != null && bitcoindeAccount.getData().getFidorReservation().getAllocation().size() > 0; final Map<String, BitcoindeBalance> bitcoindeBalances = hasBalances ? bitcoindeAccount.getData().getBalances() : new HashMap<>(); final Map<String, BitcoindeAllocation> fidorAllocations = hasAllocations ? bitcoindeAccount.getData().getFidorReservation().getAllocation() : new HashMap<>(); final Set<String> currencyStrings = new HashSet<>(); currencyStrings.addAll(bitcoindeBalances.keySet()); currencyStrings.addAll(fidorAllocations.keySet()); final List<Wallet> wallets = currencyStrings.stream() .map( currencyString -> { final Currency currency = Currency.getInstance(currencyString); final List<Balance> balances = new LinkedList<>(); if (bitcoindeBalances.containsKey(currencyString)) { final BitcoindeBalance balance = bitcoindeBalances.get(currencyString); balances.add( new Balance( Currency.getInstance(currencyString), balance.getTotalAmount(), balance.getAvailableAmount(), balance.getReservedAmount())); } if (fidorAllocations.containsKey(currencyString)) { final BitcoindeAllocation allocation = fidorAllocations.get(currencyString); balances.add( new Balance( Currency.EUR, allocation.getMaxEurVolume(), allocation .getMaxEurVolume() .subtract(allocation.getEurVolumeOpenOrders()))); } return Wallet.Builder.from(balances).id(currency.getCurrencyCode()).build(); }) .collect(Collectors.toList()); return new AccountInfo(wallets); } private  BitcoindeAdapters(); static OrderBook adaptCompactOrderBook(
      BitcoindeCompactOrderbookWrapper bitcoindeOrderbookWrapper, CurrencyPair currencyPair); static OrderBook adaptOrderBook(
      BitcoindeOrderbookWrapper asksWrapper,
      BitcoindeOrderbookWrapper bidsWrapper,
      CurrencyPair currencyPair); static List<LimitOrder> createCompactOrders(
      CurrencyPair currencyPair, OrderType orderType, BitcoindeCompactOrder[] orders); static LimitOrder createOrder(
      CurrencyPair currencyPair,
      BitcoindeOrder bitcoindeOrder,
      OrderType orderType,
      String orderId,
      Date timeStamp); static Trades adaptTrades(
      BitcoindeTradesWrapper bitcoindeTradesWrapper, CurrencyPair currencyPair); static AccountInfo adaptAccountInfo(BitcoindeAccountWrapper bitcoindeAccount); static List<FundingRecord> adaptFundingHistory(
      final Currency currency,
      final List<BitcoindeAccountLedger> accountLedgers,
      final boolean leaveFeesSeperate); static FundingRecord.Type adaptFundingRecordType(BitcoindeAccountLedgerType type); static UserTrades adaptTradeHistory(BitcoindeMyTradesWrapper bitcoindeMyTradesWrapper); static UserTrades adaptTradeHistory(
      BitcoindeMyTradesWrapper bitcoindeMyTradesWrapper, TradeSortType sortType); static OpenOrders adaptOpenOrders(BitcoindeMyOrdersWrapper bitcoindeOpenOrdersWrapper); static OrderType adaptOrderType(final BitcoindeType type); static OrderStatus adaptOrderStatus(final BitcoindeOrderState state);  }
@Test public void testAccountInfoAdapter() throws IOException { final InputStream is = BitcoindeAdaptersTest.class.getResourceAsStream( "/org/knowm/xchange/bitcoinde/v4/dto/account.json"); final ObjectMapper mapper = new ObjectMapper(); final BitcoindeAccountWrapper bitcoindeTradesWrapper = mapper.readValue(is, BitcoindeAccountWrapper.class); final AccountInfo accountInfo = BitcoindeAdapters.adaptAccountInfo(bitcoindeTradesWrapper); assertThat(accountInfo.getWallets()).containsOnlyKeys("BTC", "BCH", "BTG", "BSV", "ETH"); final Wallet btcWallet = accountInfo.getWallet("BTC"); assertThat(btcWallet.getBalances()).containsOnlyKeys(Currency.BTC, Currency.EUR); assertThat(btcWallet.getBalances().get(Currency.BTC).getAvailable()) .isEqualByComparingTo("0.009"); assertThat(btcWallet.getBalances().get(Currency.BTC).getFrozen()).isEqualByComparingTo("0"); assertThat(btcWallet.getBalances().get(Currency.BTC).getTotal()).isEqualByComparingTo("0.009"); assertThat(btcWallet.getBalances().get(Currency.EUR).getAvailable()) .isEqualByComparingTo("2000"); assertThat(btcWallet.getBalances().get(Currency.EUR).getFrozen()).isEqualByComparingTo("0"); assertThat(btcWallet.getBalances().get(Currency.EUR).getTotal()).isEqualByComparingTo("2000"); final Wallet bchWallet = accountInfo.getWallet("BCH"); assertThat(bchWallet.getBalances()).containsOnlyKeys(Currency.BCH, Currency.EUR); assertThat(bchWallet.getBalances().get(Currency.BCH).getAvailable()) .isEqualByComparingTo("0.008"); assertThat(bchWallet.getBalances().get(Currency.BCH).getFrozen()).isEqualByComparingTo("0"); assertThat(bchWallet.getBalances().get(Currency.BCH).getTotal()).isEqualByComparingTo("0.008"); assertThat(bchWallet.getBalances().get(Currency.EUR).getAvailable()).isEqualByComparingTo("0"); assertThat(bchWallet.getBalances().get(Currency.EUR).getFrozen()).isEqualByComparingTo("0"); assertThat(bchWallet.getBalances().get(Currency.EUR).getTotal()).isEqualByComparingTo("0"); final Wallet btgWallet = accountInfo.getWallet("BTG"); assertThat(btgWallet.getBalances()).containsOnlyKeys(Currency.BTG, Currency.EUR); assertThat(btgWallet.getBalances().get(Currency.BTG).getAvailable()) .isEqualByComparingTo("0.007"); assertThat(btgWallet.getBalances().get(Currency.BTG).getFrozen()).isEqualByComparingTo("0"); assertThat(btgWallet.getBalances().get(Currency.BTG).getTotal()).isEqualByComparingTo("0.007"); assertThat(btgWallet.getBalances().get(Currency.EUR).getAvailable()).isEqualByComparingTo("0"); assertThat(btgWallet.getBalances().get(Currency.EUR).getFrozen()).isEqualByComparingTo("0"); assertThat(btgWallet.getBalances().get(Currency.EUR).getTotal()).isEqualByComparingTo("0"); final Wallet bsvWallet = accountInfo.getWallet("BSV"); assertThat(bsvWallet.getBalances()).containsOnlyKeys(Currency.getInstance("BSV")); assertThat(bsvWallet.getBalances().get(Currency.getInstance("BSV")).getAvailable()) .isEqualByComparingTo("0.006"); assertThat(bsvWallet.getBalances().get(Currency.getInstance("BSV")).getFrozen()) .isEqualByComparingTo("0"); assertThat(bsvWallet.getBalances().get(Currency.getInstance("BSV")).getTotal()) .isEqualByComparingTo("0.006"); final Wallet ethWallet = accountInfo.getWallet("ETH"); assertThat(ethWallet.getBalances()).containsOnlyKeys(Currency.ETH, Currency.EUR); assertThat(ethWallet.getBalances().get(Currency.ETH).getAvailable()) .isEqualByComparingTo("0.06463044"); assertThat(ethWallet.getBalances().get(Currency.ETH).getFrozen()).isEqualByComparingTo("0"); assertThat(ethWallet.getBalances().get(Currency.ETH).getTotal()) .isEqualByComparingTo("0.06463044"); assertThat(ethWallet.getBalances().get(Currency.EUR).getAvailable()).isEqualByComparingTo("0"); assertThat(ethWallet.getBalances().get(Currency.EUR).getFrozen()).isEqualByComparingTo("0"); assertThat(ethWallet.getBalances().get(Currency.EUR).getTotal()).isEqualByComparingTo("0"); }