1 package org.oxerr.okcoin.rest.dto;
2
3 import static org.junit.Assert.assertEquals;
4
5 import java.io.IOException;
6 import java.math.BigDecimal;
7
8 import org.junit.Test;
9
10 public class OrderHistoryTest extends UnmarshalTest {
11
12 @Test
13 public void testOrderHistory() throws IOException {
14 OrderHistory history = readValue("order_history.json", OrderHistory.class);
15 assertEquals(1, history.getCurrentPage());
16 assertEquals(1, history.getPageLength());
17 assertEquals(3, history.getTotal());
18 assertEquals(1, history.getOrders().length);
19
20 Order order = history.getOrders()[0];
21 assertEquals(new BigDecimal("0"), order.getAmount());
22 assertEquals(new BigDecimal("0"), order.getAvgPrice());
23 assertEquals(1405562100000L, order.getCreateDate().toEpochMilli());
24 assertEquals(new BigDecimal("0"), order.getDealAmount());
25 assertEquals(0, order.getOrderId());
26 assertEquals(new BigDecimal("0"), order.getPrice());
27 assertEquals(Status.FULLY_FILLED, order.getStatus());
28 assertEquals("btc_cny", order.getSymbol());
29 assertEquals(Type.SELL, order.getType());
30 }
31
32 @Test
33 public void testOrderHistoryWithMarketOrders() throws IOException {
34 OrderHistory history = readValue("order_history_with_market_orders.json", OrderHistory.class);
35 assertEquals(0, history.getCurrentPage());
36 assertEquals(10, history.getPageLength());
37 assertEquals(4319, history.getTotal());
38
39
40 Order order = history.getOrders()[1];
41 assertEquals(new BigDecimal("0"), order.getAmount());
42 assertEquals(new BigDecimal("1467.99"), order.getAvgPrice());
43 assertEquals(1424315585000L, order.getCreateDate().toEpochMilli());
44 assertEquals(new BigDecimal("0.01"), order.getDealAmount());
45 assertEquals(342113073L, order.getOrderId());
46 assertEquals(new BigDecimal("15"), order.getPrice());
47 assertEquals(Status.FULLY_FILLED, order.getStatus());
48 assertEquals("btc_cny", order.getSymbol());
49 assertEquals(Type.BUY_MARKET, order.getType());
50
51
52 order = history.getOrders()[2];
53 assertEquals(new BigDecimal("0.01"), order.getAmount());
54 assertEquals(new BigDecimal("1467.98"), order.getAvgPrice());
55 assertEquals(1424315429000L, order.getCreateDate().toEpochMilli());
56 assertEquals(new BigDecimal("0.01"), order.getDealAmount());
57 assertEquals(342110762L, order.getOrderId());
58 assertEquals(new BigDecimal("0"), order.getPrice());
59 assertEquals(Status.FULLY_FILLED, order.getStatus());
60 assertEquals("btc_cny", order.getSymbol());
61 assertEquals(Type.SELL_MARKET, order.getType());
62 }
63
64 }