RippleAdapters { public static OpenOrders adaptOpenOrders( final RippleAccountOrders rippleOrders, final int scale) { final List<LimitOrder> list = new ArrayList<>(rippleOrders.getOrders().size()); for (final RippleAccountOrdersBody order : rippleOrders.getOrders()) { final OrderType orderType; final RippleAmount baseAmount; final RippleAmount counterAmount; if (order.getType().equals("buy")) { counterAmount = order.getTakerGets(); baseAmount = order.getTakerPays(); orderType = OrderType.BID; } else { baseAmount = order.getTakerGets(); counterAmount = order.getTakerPays(); orderType = OrderType.ASK; } final String baseSymbol = baseAmount.getCurrency(); final String counterSymbol = counterAmount.getCurrency(); final BigDecimal price = counterAmount .getValue() .divide(baseAmount.getValue(), scale, RoundingMode.HALF_UP) .stripTrailingZeros(); final CurrencyPair pair = new CurrencyPair(baseSymbol, counterSymbol); final RippleLimitOrder xchangeOrder = (RippleLimitOrder) new RippleLimitOrder.Builder(orderType, pair) .baseCounterparty(baseAmount.getCounterparty()) .counterCounterparty(counterAmount.getCounterparty()) .id(Long.toString(order.getSequence())) .limitPrice(price) .timestamp(null) .originalAmount(baseAmount.getValue()) .build(); list.add(xchangeOrder); } return new OpenOrders(list); } private  RippleAdapters(); static AccountInfo adaptAccountInfo(
      final RippleAccountBalances account, final String username); static OrderBook adaptOrderBook(
      final RippleOrderBook rippleOrderBook,
      final RippleMarketDataParams params,
      final CurrencyPair currencyPair); static List<LimitOrder> createOrders(
      final CurrencyPair currencyPair,
      final OrderType orderType,
      final List<RippleOrder> orders,
      final String baseCounterparty,
      final String counterCounterparty); static OpenOrders adaptOpenOrders(
      final RippleAccountOrders rippleOrders, final int scale); static UserTrade adaptTrade(
      final IRippleTradeTransaction trade,
      final TradeHistoryParams params,
      final ITransferFeeSource transferFeeSource,
      final int scale); static UserTrades adaptTrades(
      final Collection<IRippleTradeTransaction> tradesForAccount,
      final TradeHistoryParams params,
      final RippleAccountService accountService,
      final int roundingScale);  }
@Test public void adaptOpenOrdersTest() throws JsonParseException, JsonMappingException, IOException { final RippleExchange exchange = new RippleExchange(); final int roundingScale = exchange.getRoundingScale(); final InputStream is = getClass() .getResourceAsStream("/org/knowm/xchange/ripple/dto/trade/example-account-orders.json"); final ObjectMapper mapper = new ObjectMapper(); final RippleAccountOrders response = mapper.readValue(is, RippleAccountOrders.class); final OpenOrders orders = RippleAdapters.adaptOpenOrders(response, roundingScale); assertThat(orders.getOpenOrders()).hasSize(12); final LimitOrder firstOrder = orders.getOpenOrders().get(0); assertThat(firstOrder).isInstanceOf(RippleLimitOrder.class); assertThat(firstOrder.getCurrencyPair()).isEqualTo(CurrencyPair.XRP_BTC); assertThat(((RippleLimitOrder) firstOrder).getCounterCounterparty()) .isEqualTo("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"); assertThat(firstOrder.getId()).isEqualTo("5"); assertThat(firstOrder.getLimitPrice()).isEqualTo("0.00003226"); assertThat(firstOrder.getTimestamp()).isNull(); assertThat(firstOrder.getOriginalAmount()).isEqualTo("1"); assertThat(firstOrder.getType()).isEqualTo(OrderType.BID); final LimitOrder secondOrder = orders.getOpenOrders().get(1); assertThat(secondOrder).isInstanceOf(RippleLimitOrder.class); assertThat(secondOrder.getCurrencyPair()).isEqualTo(CurrencyPair.XRP_BTC); assertThat(((RippleLimitOrder) secondOrder).getCounterCounterparty()) .isEqualTo("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"); assertThat(secondOrder.getId()).isEqualTo("7"); assertThat(secondOrder.getLimitPrice()) .isEqualTo("123.12345677999998635515884154518859509596611713043533"); assertThat(secondOrder.getTimestamp()).isNull(); assertThat(secondOrder.getOriginalAmount()).isEqualTo("123.123456"); assertThat(secondOrder.getType()).isEqualTo(OrderType.ASK); }