BittrexAdapters { public static List<LimitOrder> adaptOrders( BittrexLevel[] orders, CurrencyPair currencyPair, OrderType orderType, int depth) { if (orders == null || orders.length == 0) { return new ArrayList<>(); } return Arrays.stream(orders) .limit(Math.min(orders.length, depth)) .map( order -> new LimitOrder.Builder(orderType, currencyPair) .originalAmount(order.getAmount()) .limitPrice(order.getPrice()) .build()) .collect(Collectors.toList()); } private  BittrexAdapters(); static List<CurrencyPair> adaptCurrencyPairs(Collection<BittrexSymbol> bittrexSymbols); static CurrencyPair adaptCurrencyPair(BittrexSymbol bittrexSymbol); static List<LimitOrder> adaptOpenOrders(List<BittrexOrder> bittrexOpenOrders); static List<LimitOrder> adaptOrders(
      BittrexLevel[] orders, CurrencyPair currencyPair, OrderType orderType, int depth); static LimitOrder adaptOrder(BittrexOrder order); static LimitOrder adaptOrder(BittrexOrder order, OrderStatus status); static OrderStatus adaptOrderStatus(BittrexOrder order); static Trade adaptTrade(BittrexTrade trade, CurrencyPair currencyPair); static Trades adaptTrades(List<BittrexTrade> trades, CurrencyPair currencyPair); static List<UserTrade> adaptUserTrades(List<BittrexOrder> bittrexUserTrades); static Ticker adaptTicker(
      BittrexMarketSummary bittrexMarketSummary, BittrexTicker bittrexTicker); static Wallet adaptWallet(Collection<BittrexBalance> balances); static void adaptMetaData(List<BittrexSymbol> rawSymbols, ExchangeMetaData metaData);  }
@Test public void testAdaptOrders() { BittrexLevel ask1 = new BittrexLevel(new BigDecimal("10"), new BigDecimal("1")); BittrexLevel ask2 = new BittrexLevel(new BigDecimal("11"), new BigDecimal("2")); BittrexLevel ask3 = new BittrexLevel(new BigDecimal("12"), new BigDecimal("3")); BittrexLevel bid1 = new BittrexLevel(new BigDecimal("9"), new BigDecimal("4")); BittrexLevel bid2 = new BittrexLevel(new BigDecimal("8"), new BigDecimal("5")); BittrexLevel bid3 = new BittrexLevel(new BigDecimal("7"), new BigDecimal("6")); BittrexLevel[] asks = {ask1, ask2, ask3}; BittrexLevel[] bids = {bid1, bid2, bid3}; CurrencyPair currencyPair = CurrencyPair.ETH_BTC; Order.OrderType askType = Order.OrderType.ASK; Order.OrderType bidType = Order.OrderType.BID; int depth = 2; List<LimitOrder> expectedAsks = Arrays.asList( new LimitOrder(askType, ask1.getAmount(), currencyPair, null, null, ask1.getPrice()), new LimitOrder(askType, ask2.getAmount(), currencyPair, null, null, ask2.getPrice())); List<LimitOrder> expectedBids = Arrays.asList( new LimitOrder(bidType, bid1.getAmount(), currencyPair, null, null, bid1.getPrice()), new LimitOrder(bidType, bid2.getAmount(), currencyPair, null, null, bid2.getPrice())); List<LimitOrder> adaptedAsks = BittrexAdapters.adaptOrders(asks, currencyPair, askType, depth); List<LimitOrder> adaptedBids = BittrexAdapters.adaptOrders(bids, currencyPair, bidType, depth); Assert.assertEquals(expectedAsks, adaptedAsks); Assert.assertEquals(expectedBids, adaptedBids); }