View Javadoc
1   package org.oxerr.okcoin.rest.dto;
2   
3   import static org.junit.Assert.assertEquals;
4   
5   import java.math.BigDecimal;
6   
7   import org.junit.BeforeClass;
8   import org.junit.Test;
9   
10  import com.fasterxml.jackson.core.JsonProcessingException;
11  import com.fasterxml.jackson.databind.ObjectMapper;
12  import com.fasterxml.jackson.databind.SerializationFeature;
13  
14  public class OrderDataTest {
15  
16  	private static final ObjectMapper mapper = new ObjectMapper();
17  
18  	@BeforeClass
19  	public static void setUpBeforeClass() throws Exception {
20  		mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
21  	}
22  
23  	@Test
24  	public void test() throws JsonProcessingException {
25  		OrderData[] orders = new OrderData[] {
26  			new OrderData(new BigDecimal("0.01"), new BigDecimal("1"), Type.BUY),
27  			new OrderData(new BigDecimal("0.02"), new BigDecimal("2"), Type.BUY),
28  		};
29  
30  		assertEquals("[{\"price\":0.01,\"amount\":1,\"type\":\"buy\"},{\"price\":0.02,\"amount\":2,\"type\":\"buy\"}]",
31  			mapper.writeValueAsString(orders));
32  	}
33  
34  }