package yahoofinance;

import org.junit.Test;
import yahoofinance.histquotes.HistoricalQuote;
import yahoofinance.histquotes.Interval;
import yahoofinance.mock.MockedServersTest;
import yahoofinance.quotes.fx.FxQuote;
import yahoofinance.quotes.fx.FxSymbols;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.*;

/**
 *
 * @author Stijn Strickx
 */
public class FxQuoteRequestTest extends MockedServersTest {

    @Test
    public void fxQuoteTest() throws IOException {
        FxQuote gbpeur = YahooFinance.getFx(FxSymbols.GBPEUR);
        assertEquals(new BigDecimal("1.1806"), gbpeur.getPrice());
        assertEquals(FxSymbols.GBPEUR, gbpeur.getSymbol());

        FxQuote usdeur = YahooFinance.getFx(FxSymbols.USDEUR);
        assertEquals(new BigDecimal("0.8898"), usdeur.getPrice());

        Map<String, FxQuote> fxQuotes = YahooFinance.getFx(new String[]{FxSymbols.EURUSD, FxSymbols.EURCHF});
        FxQuote eurusd = fxQuotes.get(FxSymbols.EURUSD);
        FxQuote eurchf = fxQuotes.get(FxSymbols.EURCHF);
        assertEquals(new BigDecimal("1.1235"), eurusd.getPrice());
        assertEquals(FxSymbols.EURUSD, eurusd.getSymbol());
        assertEquals(new BigDecimal("1.0954"), eurchf.getPrice());
        assertEquals(FxSymbols.EURCHF, eurchf.getSymbol());
    }

    @Test
    public void fxFlowTest() throws IOException {
        int requestCount = MockedServersTest.quotesServer.getRequestCount();
        FxQuote gbpeur = YahooFinance.getFx(FxSymbols.GBPEUR);
        requestCount += 1;
        assertEquals(requestCount, MockedServersTest.quotesServer.getRequestCount());
        gbpeur.getPrice();
        assertEquals(requestCount, MockedServersTest.quotesServer.getRequestCount());
        gbpeur.getPrice(true);
        requestCount += 1;
        assertEquals(requestCount, MockedServersTest.quotesServer.getRequestCount());
    }
}

@@ -43,97 +43,8 @@
 st;%0A
-import yahoofinance.histquotes.HistoricalQuote;%0Aimport yahoofinance.histquotes.Interval;%0A
 impo
@@ -225,58 +225,8 @@
 al;%0A
-import java.util.Calendar;%0Aimport java.util.List;%0A
 impo

Remove unused imports