package com.github.vedenin.codingchallenge;

import com.github.vedenin.codingchallenge.common.CurrencyEnum;
import com.github.vedenin.codingchallenge.restclient.RestClient;
import com.github.vedenin.codingchallenge.restclient.impl.currencylayer.CurrencyLayerRestClient;
import org.junit.Assert;
import org.junit.Test;

import java.math.BigDecimal;
import java.util.GregorianCalendar;

/**
 * Created by vvedenin on 2/10/2017.
 */

public class CurrencyLayerRestClientTest {
    @Test
    public void ExternalTest() {
        RestClient restClient = new CurrencyLayerRestClient();
        BigDecimal convertRates = restClient.getCurrentExchangeRates(CurrencyEnum.EUR, CurrencyEnum.RUB);
        Assert.assertTrue(convertRates.doubleValue() > 0.0);
        convertRates = restClient.getHistoricalExchangeRates(CurrencyEnum.EUR, CurrencyEnum.RUB, new GregorianCalendar(2010, 10, 17));
        Assert.assertEquals(convertRates.doubleValue(), 42.6, 0.5);
        convertRates = restClient.getHistoricalExchangeRates(CurrencyEnum.EUR, CurrencyEnum.RUB, new GregorianCalendar(2012, 1, 1));
        Assert.assertEquals(convertRates.doubleValue(), 39.7, 0.5);
    }

}

@@ -101,16 +101,90 @@
 cyEnum;%0A
+import com.github.vedenin.codingchallenge.exceptions.RestClientException;%0A
 import c
@@ -1225,10 +1225,633 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void ExternalErrorTest() %7B%0A        RestClient restClient = new CurrencyLayerRestClient();%0A        try %7B%0A            BigDecimal convertRates = restClient.getHistoricalExchangeRates(CurrencyEnum.EUR, CurrencyEnum.RUB, new GregorianCalendar(2110, 12, 47));%0A            Assert.fail(%22Must be run RestClientException%22);%0A        %7D catch (RestClientException exception) %7B%0A            Assert.assertEquals(%22Error while gathering information from CurrencyLayer services, code:106, error:%22 +%0A                    %22Your query did not return any results. Please try again.%22, exception.getMessage());%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Add ExternalErrorTest in RestTest