View Javadoc
1   package org.oxerr.okcoin.rest.dto;
2   
3   import static org.junit.Assert.assertEquals;
4   import static org.junit.Assert.fail;
5   
6   import java.io.IOException;
7   
8   import org.junit.Test;
9   import org.oxerr.okcoin.rest.OKCoinException;
10  
11  import com.fasterxml.jackson.core.JsonParseException;
12  import com.fasterxml.jackson.databind.JsonMappingException;
13  
14  /**
15   * Test for parsing the result of /api/trade.do.
16   */
17  public class TradeTest extends UnmarshalTest {
18  
19  	@Test
20  	public void test() throws JsonParseException, JsonMappingException,
21  			IOException {
22  		TradeResult tradeResult = readValue("trade.json", TradeResult.class);
23  
24  		assertEquals(123456L, tradeResult.getOrderId());
25  	}
26  
27  	@Test
28  	public void testError() throws JsonParseException, JsonMappingException,
29  			IOException {
30  		try {
31  			readValue("trade-error.json", TradeResult.class);
32  			fail("A JsonMappingException should be thrown.");
33  		} catch (JsonMappingException e) {
34  			assertEquals(10000, ((OKCoinException) e.getCause()).getErrorCode().intValue());
35  		}
36  	}
37  
38  }