@Sql("/sql/insert_data_histo.sql")
@Test
public void testAdd() throws Exception {

	// given
	String symbol = "UBI.PA";
	String name = "Ubi";
	String provider = "Provider";
	when(lookupService.search(provider)).thenReturn(asList(new LookupInfo(symbol, name, "Paris", "Titres", provider)));
	when(lookupService.getDetails(symbol, provider)).thenReturn(new LookupDetails(symbol, name, "UBI", "EUR", "EPA", provider));
	Quote histoQuote = new Quote(symbol, new BigDecimal("25.2"), parse("2016-06-30T02:00:00+02:00"));
	Quote latestQuote = new Quote(symbol, new BigDecimal("25"), parse("2016-06-30T19:32:00+02:00"));
	
	when(rateProviderService.getHistoricalProvider(ProviderType.STOCK)).thenReturn(hrp);
	when(rateProviderService.getLatestProvider(ProviderType.STOCK)).thenReturn(lrp);
	
	when(hrp.getHistoricalRates(symbol)).thenReturn(asList(histoQuote));
	when(lrp.getLatestRate(symbol)).thenReturn(latestQuote);
	// when
	SymbolInfo result = adminService.add(symbol, provider);
	// then
	Pair pairResult = pairService.getForCodeAndProvider(symbol, provider);
	assertThat(result.getCode()).isEqualTo(pairResult.getSymbol());
	assertThat(result.getName()).isEqualTo(pairResult.getName());
	assertThat(result.getQuote().getCode()).isEqualTo(pairResult.getSource().getCode());
	assertThat(result.getQuote().getCurrency()).isEqualTo(pairResult.getTarget().getCode());
	assertThat(result.getQuote().getPrice()).isEqualTo("25");
	assertThat(result.getQuote().getTime()).isEqualTo(parse("2016-06-30T19:32:00+02:00"));
	BooleanExpression exp = historicalRate.fromcur.code.eq("UBI").and(historicalRate.tocur.code.eq("EUR"));
	assertThat(hRateRepo.count(exp)).isEqualTo(2);
	assertThat(rateService.getLatest("UBI", "EUR")).isNotNull();
}