RateService { @Transactional public void addHistoricalRates(List<Quote> quotes) { List<HistoricalRate> ratesToAdd = new ArrayList<>(); for (Quote quote : quotes) { BooleanExpression exp = historicalRate.fromcur.code.eq(quote.getCode()) .and(historicalRate.tocur.code.eq(quote.getCurrency())) .and(historicalRate.date.eq(quote.getTime())); if (!historicalRateRepository.exists(exp)) { SymbolEntity symbolCode = symbolRepository.findById(quote.getCode()).get(); SymbolEntity symbolCurrency = symbolRepository.findById(quote.getCurrency()).get(); ratesToAdd.add(new HistoricalRate(symbolCode, symbolCurrency, quote.getPrice(), quote.getTime())); } } historicalRateRepository.saveAll(ratesToAdd); log.debug("{} saved", ratesToAdd.size()); }  List<FavoriteRate> getAllLatestWithFavorites(String username); Instant getOldestRateDate(String fromcur, String tocur); Instant getNewestRateDate(String fromcur, String tocur); Rate getLatest(String fromcur, String tocur); void addLatestRate(Quote quote); List<DateValue> getHistoricalValues(String fromcur, String tocur, Instant startDate, Instant endDate); @Transactional void addHistoricalRates(List<Quote> quotes);  }
@Sql("/sql/insert_histo.sql") @Test public void testAddHistoricalRates() { List<Quote> quotes = new ArrayList<>(); quotes.add(new Quote(BRE, USD, new BigDecimal("58.3"), parse("2015-04-09T02:00:00"))); quotes.add(new Quote(BRE, USD, new BigDecimal("57.8"), parse("2015-04-08T02:00:00"))); quotes.add(new Quote(BRE, USD, new BigDecimal("55.18"), parse("2015-04-07T02:00:00"))); quotes.add(new Quote(BRE, USD, new BigDecimal("56.72"), parse("2015-04-03T02:00:00"))); quotes.add(new Quote(BRE, USD, new BigDecimal("55.18"), parse("2015-04-02T02:00:00"))); rateService.addHistoricalRates(quotes); assertThat(histoRepo.findAll()).hasSize(5); }