package mic.trade.gatecoin;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import mic.trade.bean.MarketDepth;
import mic.trade.bean.Transaction;
import mic.trade.gatecoin.json.MarketDepthJsonDeserializer;

public class TestGatecoinTradeService {
	public static final String TESTING_CURRENCY = "ETHHKD";
	
	private GatecoinTradeService tradeService = null;
	
	@Before
	public void beforeTest() {
		tradeService = new GatecoinTradeService();
	}
	
	@After
	public void afterTest() {
		tradeService.closeService();
	}
	
	@Test
	public void testGetRecentTransaction() {
		List<Transaction> transactionList = tradeService.getTransactionList(TESTING_CURRENCY, false);
		assertNotNull(transactionList);
		
		int listSize = transactionList.size();
		
		assertTrue(listSize > 0);
		
		//Test overload method
		transactionList = tradeService.getTransactionList(TESTING_CURRENCY);
		
		//Size should be the same
		assertEquals(listSize, transactionList.size());
	}
	
	@Test
	public void testGetTransactionHistory() {
		List<Transaction> transactionList = tradeService.getTransactionList(TESTING_CURRENCY, true);
		assertNotNull(transactionList);
		assertTrue(transactionList.size() > 0);
	}
	
	@Test
	public void testGetMarketDepth() {
		MarketDepth marketDepth = tradeService.getMarketDepth(TESTING_CURRENCY, 
				MarketDepthJsonDeserializer.JSON_TYPE_FILTER_MODE_BIDASK);
		
		assertTrue(marketDepth.getAskUnits().size() > 0);
		assertTrue(marketDepth.getBidUnits().size() > 0);
		
		//Test overload method
		marketDepth = tradeService.getMarketDepth(TESTING_CURRENCY);
		
		assertTrue(marketDepth.getAskUnits().size() > 0);
		assertTrue(marketDepth.getBidUnits().size() > 0);
		
		//Test bidUnit Filter
		marketDepth = tradeService.getMarketDepth(TESTING_CURRENCY, 
				MarketDepthJsonDeserializer.JSON_TYPE_FILTER_MODE_BID);
		
		assertTrue(marketDepth.getAskUnits().size() == 0);
		assertTrue(marketDepth.getBidUnits().size() > 0);
		
		//Test bidUnit Filter
		marketDepth = tradeService.getMarketDepth(TESTING_CURRENCY, 
				MarketDepthJsonDeserializer.JSON_TYPE_FILTER_MODE_ASK);
		
		assertTrue(marketDepth.getAskUnits().size() > 0);
		assertTrue(marketDepth.getBidUnits().size() == 0);
	}
}

@@ -848,32 +848,81 @@
 %09%09assertNotNull(
+%22transactionList should not be null if success%22, 
 transactionList)
@@ -983,16 +983,61 @@
 ertTrue(
+%22transactionList.size should %3E 0 if normal%22, 
 listSize
@@ -1188,16 +1188,64 @@
 tEquals(
+%22transactionList.size() should same as before%22, 
 listSize
@@ -1441,39 +1441,133 @@
 ull(
-transactionList);%0A%09%09assertTrue(
+%22transactionList should not be null if success%22, transactionList);%0A%09%09assertTrue(%22transactionList.size should %3E 0 if normal%22, 
 tran
@@ -1785,32 +1785,65 @@
 %09%09%0A%09%09assertTrue(
+%22Ask.size should %3E 0 if normal%22, 
 marketDepth.getA
@@ -1870,32 +1870,65 @@
 );%0A%09%09assertTrue(
+%22Bid.size should %3E 0 if normal%22, 
 marketDepth.getB
@@ -2049,32 +2049,65 @@
 %09%09%0A%09%09assertTrue(
+%22Ask.size should %3E 0 if normal%22, 
 marketDepth.getA
@@ -2134,32 +2134,65 @@
 );%0A%09%09assertTrue(
+%22Bid.size should %3E 0 if normal%22, 
 marketDepth.getB
@@ -2372,32 +2372,78 @@
 %09%09%0A%09%09assertTrue(
+%22Ask.size should == 0 if in bid filter mode%22, 
 marketDepth.getA
@@ -2471,32 +2471,65 @@
 );%0A%09%09assertTrue(
+%22Bid.size should %3E 0 if normal%22, 
 marketDepth.getB
@@ -2709,32 +2709,65 @@
 %09%09%0A%09%09assertTrue(
+%22Ask.size should %3E 0 if normal%22, 
 marketDepth.getA
@@ -2802,16 +2802,62 @@
 ertTrue(
+%22Bid.size should == 0 if in bid filter mode%22, 
 marketDe

Add fail message to junit test case