BTCTradeAdapters { public static Trades adaptTrades(BTCTradeTrade[] btcTradeTrades, CurrencyPair currencyPair) { int length = btcTradeTrades.length; List<Trade> trades = new ArrayList<>(length); for (BTCTradeTrade btcTradeTrade : btcTradeTrades) { trades.add(adaptTrade(btcTradeTrade, currencyPair)); } long lastID = length > 0 ? btcTradeTrades[length - 1].getTid() : 0L; return new Trades(trades, lastID, TradeSortType.SortByID); } 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 testAdaptTradesBTCTradeTradeArrayCurrencyPair() throws IOException { BTCTradeTrade[] btcTradeTrades = mapper.readValue( getClass().getResource("dto/marketdata/trades.json"), BTCTradeTrade[].class); Trades trades = BTCTradeAdapters.adaptTrades(btcTradeTrades, CurrencyPair.BTC_CNY); List<Trade> tradeList = trades.getTrades(); assertEquals(new Date(1403397140L * 1000L), tradeList.get(0).getTimestamp()); assertEquals(new BigDecimal("3703"), tradeList.get(0).getPrice()); assertEquals(new BigDecimal("3.50000000000"), tradeList.get(0).getOriginalAmount()); assertEquals("2895575", tradeList.get(0).getId()); assertEquals(OrderType.BID, tradeList.get(0).getType()); assertEquals(new Date(1403397191L * 1000L), tradeList.get(1).getTimestamp()); assertEquals(new BigDecimal("3704"), tradeList.get(1).getPrice()); assertEquals(new BigDecimal("0.00200000000"), tradeList.get(1).getOriginalAmount()); assertEquals("2895576", tradeList.get(1).getId()); assertEquals(OrderType.BID, tradeList.get(1).getType()); assertEquals(new Date(1403428819L * 1000L), tradeList.get(tradeList.size() - 2).getTimestamp()); assertEquals(new BigDecimal("3740.01"), tradeList.get(tradeList.size() - 2).getPrice()); assertEquals( new BigDecimal("0.01000000000"), tradeList.get(tradeList.size() - 2).getOriginalAmount()); assertEquals("2896235", tradeList.get(tradeList.size() - 2).getId()); assertEquals(OrderType.ASK, tradeList.get(tradeList.size() - 2).getType()); assertEquals(new Date(1403428797L * 1000L), tradeList.get(tradeList.size() - 1).getTimestamp()); assertEquals(new BigDecimal("3752"), tradeList.get(tradeList.size() - 1).getPrice()); assertEquals( new BigDecimal("16.70000000000"), tradeList.get(tradeList.size() - 1).getOriginalAmount()); assertEquals("2896239", tradeList.get(tradeList.size() - 1).getId()); assertEquals(OrderType.BID, tradeList.get(tradeList.size() - 1).getType()); }