@Test
public void testAdaptOrderBook() throws IOException {
BTCChinaGetMarketDepthResponse response = mapper.readValue(getClass().getResourceAsStream("dto/trade/response/getMarketDepth2.json"), BTCChinaGetMarketDepthResponse.class);
OrderBook orderBook = BTCChinaAdapters.adaptOrderBook(response.getResult().getMarketDepth(), CurrencyPair.BTC_CNY);
List<LimitOrder> bids = orderBook.getBids();
List<LimitOrder> asks = orderBook.getAsks();
assertEquals(2, bids.size());
assertEquals(2, asks.size());
// bid 1@99
assertEquals(new BigDecimal("99"), bids.get(0).getLimitPrice());
assertEquals(new BigDecimal("1"), bids.get(0).getTradableAmount());
assertEquals(CurrencyPair.BTC_CNY, bids.get(0).getCurrencyPair());
assertEquals(OrderType.BID, bids.get(0).getType());
// bid 2@98
assertEquals(new BigDecimal("98"), bids.get(1).getLimitPrice());
assertEquals(new BigDecimal("2"), bids.get(1).getTradableAmount());
assertEquals(CurrencyPair.BTC_CNY, bids.get(1).getCurrencyPair());
assertEquals(OrderType.BID, bids.get(1).getType());
// ask 0.997@100
assertEquals(new BigDecimal("100"), asks.get(0).getLimitPrice());
assertEquals(new BigDecimal("0.997"), asks.get(0).getTradableAmount());
assertEquals(CurrencyPair.BTC_CNY, asks.get(0).getCurrencyPair());
assertEquals(OrderType.ASK, asks.get(0).getType());
// ask 2@101
assertEquals(new BigDecimal("101"), asks.get(1).getLimitPrice());
assertEquals(new BigDecimal("2"), asks.get(1).getTradableAmount());
assertEquals(CurrencyPair.BTC_CNY, asks.get(1).getCurrencyPair());
assertEquals(OrderType.ASK, asks.get(1).getType());
assertEquals(1407060232000L, orderBook.getTimeStamp().getTime());
}