package org.knowm.xchange.btcturk.service.marketdata;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.ExchangeFactory;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.btcturk.BTCTurkExchange;
import org.knowm.xchange.btcturk.dto.marketdata.BTCTurkOHLC;
import org.knowm.xchange.btcturk.dto.marketdata.BTCTurkOrderBook;
import org.knowm.xchange.btcturk.service.BTCTurkDemoUtilsTest;
import org.knowm.xchange.btcturk.service.BTCTurkMarketDataService;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.marketdata.Trades;
import org.knowm.xchange.service.marketdata.MarketDataService;
import org.knowm.xchange.service.marketdata.params.Params;

/** @author semihunaldi 
 *  @author mertguner */
public class MarketDataFetchIntegrationTest {

	private Exchange btcTurk;
	private BTCTurkMarketDataService btcTurkMarketDataService;
	
	@Before
	public void InitExchange() throws IOException 
	{
		if(BTCTurkDemoUtilsTest.BTCTURK_APIKEY.isEmpty())
			btcTurk = ExchangeFactory.INSTANCE.createExchange(BTCTurkExchange.class.getName());
		else
		{
			ExchangeSpecification exSpec = new BTCTurkExchange().getDefaultExchangeSpecification();
    			exSpec.setApiKey(BTCTurkDemoUtilsTest.BTCTURK_APIKEY);
    			exSpec.setSecretKey(BTCTurkDemoUtilsTest.BTCTURK_SECRETKEY); 
    			btcTurk = ExchangeFactory.INSTANCE.createExchange(exSpec);
		}
    	
    	MarketDataService marketDataService = btcTurk.getMarketDataService();
    	btcTurkMarketDataService = (BTCTurkMarketDataService)marketDataService;
	}
	
  @Test
  public void TickerTest() throws Exception {
    Ticker ticker = btcTurkMarketDataService.getTicker(new CurrencyPair("BTC", "TRY"));
    System.out.println(ticker.toString());
    assertThat(ticker).isNotNull();
    
    List<Ticker> tickers = btcTurkMarketDataService.getTickers(new Params() {});
    for(Ticker _ticker : tickers)
    {
    	System.out.println(_ticker.toString());
        assertThat(_ticker).isNotNull();
    }
    
  }
  
  @Test
  public void TradesTest() throws Exception {
	  Trades trades = btcTurkMarketDataService.getTrades(CurrencyPair.BTC_TRY);
		assertThat(trades.getTrades().size()).isEqualTo(50);
		 
		trades = btcTurkMarketDataService.getTrades(CurrencyPair.BTC_TRY, 5);
		assertThat(trades.getTrades().size()).isEqualTo(5);
  }
  
  @Test
	public void OHCLTest() throws IOException 
	{
		List<BTCTurkOHLC> btcTurkBTCTurkOHLC = btcTurkMarketDataService.getBTCTurkOHLC(CurrencyPair.BTC_TRY);
		assertThat(btcTurkBTCTurkOHLC.size()).isNotEqualTo(0); //Daily size is always changing
		
		List<BTCTurkOHLC> btcTurkBTCTurkOHLC2 = btcTurkMarketDataService.getBTCTurkOHLC(CurrencyPair.BTC_TRY, 2);
		assertThat(btcTurkBTCTurkOHLC2.size()).isEqualTo(2);
	}
  
  @Test
	public void OrderBookTest() throws IOException 
	{
		BTCTurkOrderBook btcTurkBTCTurkOrderBook = btcTurkMarketDataService.getBTCTurkOrderBook(CurrencyPair.BTC_TRY);
		assertThat(btcTurkBTCTurkOrderBook.getAsks().size()).isEqualTo(100); 
		assertThat(btcTurkBTCTurkOrderBook.getBids().size()).isEqualTo(100); 
	}
  
  
}

@@ -1779,22 +1779,16 @@
 ic void 
-Ticker
 Test() t
@@ -1805,20 +1805,34 @@
 ption %7B%0A
-    
+%09  //Ticker Test%0A%09
 Ticker t
@@ -1907,20 +1907,17 @@
 TRY%22));%0A
-    
+%09
 System.o
@@ -1947,20 +1947,17 @@
 ing());%0A
-    
+%09
 assertTh
@@ -1985,20 +1985,17 @@
 );%0A    %0A
-    
+%09
 List%3CTic
@@ -2063,20 +2063,17 @@
 () %7B%7D);%0A
-    
+%09
 for(Tick
@@ -2098,18 +2098,12 @@
 rs)%0A
-    %7B%0A    
+%09%7B%0A%09
 %09Sys
@@ -2143,16 +2143,10 @@
 ));%0A
-        
+%09%09
 asse
@@ -2178,83 +2178,31 @@
 ();%0A
-    %7D%0A    %0A  
+%09
 %7D%0A  
-%0A
   
-@Test%0A  public void TradesTest() throws Exception %7B%0A%09  
+%0A%09//TradesTest%0A%09
 Trad
@@ -2263,33 +2263,32 @@
 yPair.BTC_TRY);%0A
-%09
 %09assertThat(trad
@@ -2329,17 +2329,16 @@
 0);%0A%09%09 %0A
-%09
 %09trades 
@@ -2400,17 +2400,16 @@
 RY, 5);%0A
-%09
 %09assertT
@@ -2457,71 +2457,27 @@
 5);%0A
+%09
   
-%7D%0A  %0A  @Test%0A%09public void OHCLTest() throws IOException %0A%09%7B%0A%09
+%0A%09//OHCLTest%09  %0A
 %09Lis
@@ -2567,33 +2567,32 @@
 yPair.BTC_TRY);%0A
-%09
 %09assertThat(btcT
@@ -2666,17 +2666,16 @@
 ging%0A%09%09%0A
-%09
 %09List%3CBT
@@ -2773,17 +2773,16 @@
 RY, 2);%0A
-%09
 %09assertT
@@ -2832,74 +2832,28 @@
 );%0A%09
-%7D%0A
   %0A
-  @Test%0A%09public void OrderBookTest() throws IOException %0A%09%7B%0A%09
+%09//OrderBookTest%0A
 %09BTC
@@ -2960,17 +2960,16 @@
 C_TRY);%0A
-%09
 %09assertT
@@ -3031,17 +3031,16 @@
 (100); %0A
-%09
 %09assertT
@@ -3106,15 +3106,10 @@
 ); %0A
-%09%7D%0A  %0A
   
+%7D
 %0A%7D%0A

Update MarketDataFetchIntegrationTest.java