test_class.declarator: BRE = "BRE"
test_class.modifier: private static final
test_class.original_string: private static final String BRE = "BRE";
test_class.type: String
test_class.var_name: BRE
test_class.declarator: histoRepo
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private HistoricalRateRepository histoRepo;
test_class.type: HistoricalRateRepository
test_class.var_name: histoRepo
test_class.declarator: rateService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private RateService rateService;
test_class.type: RateService
test_class.var_name: rateService
test_class.file: trading-common/src/test/java/fr/ymanvieu/trading/common/rate/RateServiceTest.java
test_class.identifier: RateServiceTest
test_case.body: @Sql("/sql/insert_histo.sql")
  	@Test
  	public void testAddHistoricalRates() {
  		// given
  		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")));
  
  		// when
  		rateService.addHistoricalRates(quotes);
  
  		// then
  		assertThat(histoRepo.findAll()).hasSize(5);
  	}
test_case.class_method_signature: RateServiceTest.testAddHistoricalRates()
test_case.full_signature: @Sql("/sql/insert_histo.sql") @Test public void testAddHistoricalRates()
test_case.identifier: testAddHistoricalRates
test_case.invocations: add parse add parse add parse add parse add parse addHistoricalRates hasSize assertThat findAll
test_case.modifiers: @Sql("/sql/insert_histo.sql") @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAddHistoricalRates()
focal_class.declarator: BASE_CURRENCY = CurrencyUtils.USD
focal_class.modifier: private static final
focal_class.original_string: private static final String BASE_CURRENCY = CurrencyUtils.USD;
focal_class.type: String
focal_class.var_name: BASE_CURRENCY
focal_class.declarator: SORT_ASC_DATE = Sort.by(Direction.ASC, "date")
focal_class.modifier: private static final
focal_class.original_string: private static final Sort SORT_ASC_DATE = Sort.by(Direction.ASC, "date");
focal_class.type: Sort
focal_class.var_name: SORT_ASC_DATE
focal_class.declarator: SORT_DESC_DATE = Sort.by(Direction.DESC, "date")
focal_class.modifier: private static final
focal_class.original_string: private static final Sort SORT_DESC_DATE = Sort.by(Direction.DESC, "date");
focal_class.type: Sort
focal_class.var_name: SORT_DESC_DATE
focal_class.declarator: historicalRateRepository
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private HistoricalRateRepository historicalRateRepository;
focal_class.type: HistoricalRateRepository
focal_class.var_name: historicalRateRepository
focal_class.declarator: latestRateRepository
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private LatestRateRepository latestRateRepository;
focal_class.type: LatestRateRepository
focal_class.var_name: latestRateRepository
focal_class.declarator: symbolRepository
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private SymbolRepository symbolRepository;
focal_class.type: SymbolRepository
focal_class.var_name: symbolRepository
focal_class.declarator: rateMapper
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private RateMapper rateMapper;
focal_class.type: RateMapper
focal_class.var_name: rateMapper
focal_class.file: trading-common/src/main/java/fr/ymanvieu/trading/common/rate/RateService.java
focal_class.identifier: RateService
focal_class.class_method_signature: RateService.getAllLatestWithFavorites(String username)
focal_class.full_signature: public List<FavoriteRate> getAllLatestWithFavorites(String username)
focal_class.identifier: getAllLatestWithFavorites
focal_class.modifiers: public
focal_class.parameters: (String username)
focal_class.return: List<FavoriteRate>
focal_class.signature: List<FavoriteRate> getAllLatestWithFavorites(String username)
focal_class.class_method_signature: RateService.getOldestRateDate(String fromcur, String tocur)
focal_class.full_signature: public Instant getOldestRateDate(String fromcur, String tocur)
focal_class.identifier: getOldestRateDate
focal_class.modifiers: public
focal_class.parameters: (String fromcur, String tocur)
focal_class.return: Instant
focal_class.signature: Instant getOldestRateDate(String fromcur, String tocur)
focal_class.class_method_signature: RateService.getNewestRateDate(String fromcur, String tocur)
focal_class.full_signature: public Instant getNewestRateDate(String fromcur, String tocur)
focal_class.identifier: getNewestRateDate
focal_class.modifiers: public
focal_class.parameters: (String fromcur, String tocur)
focal_class.return: Instant
focal_class.signature: Instant getNewestRateDate(String fromcur, String tocur)
focal_class.class_method_signature: RateService.getLatest(String fromcur, String tocur)
focal_class.full_signature: public Rate getLatest(String fromcur, String tocur)
focal_class.identifier: getLatest
focal_class.modifiers: public
focal_class.parameters: (String fromcur, String tocur)
focal_class.return: Rate
focal_class.signature: Rate getLatest(String fromcur, String tocur)
focal_class.class_method_signature: RateService.addLatestRate(Quote quote)
focal_class.full_signature: public void addLatestRate(Quote quote)
focal_class.identifier: addLatestRate
focal_class.modifiers: public
focal_class.parameters: (Quote quote)
focal_class.return: void
focal_class.signature: void addLatestRate(Quote quote)
focal_class.class_method_signature: RateService.getHistoricalValues(String fromcur, String tocur, Instant startDate, Instant endDate)
focal_class.full_signature: public List<DateValue> getHistoricalValues(String fromcur, String tocur, Instant startDate, Instant endDate)
focal_class.identifier: getHistoricalValues
focal_class.modifiers: public
focal_class.parameters: (String fromcur, String tocur, Instant startDate, Instant endDate)
focal_class.return: List<DateValue>
focal_class.signature: List<DateValue> getHistoricalValues(String fromcur, String tocur, Instant startDate, Instant endDate)
focal_class.class_method_signature: RateService.addHistoricalRates(List<Quote> quotes)
focal_class.full_signature: @Transactional public void addHistoricalRates(List<Quote> quotes)
focal_class.identifier: addHistoricalRates
focal_class.modifiers: @Transactional public
focal_class.parameters: (List<Quote> quotes)
focal_class.return: void
focal_class.signature: void addHistoricalRates(List<Quote> quotes)
focal_method.body: @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());
  	}
focal_method.class_method_signature: RateService.addHistoricalRates(List<Quote> quotes)
focal_method.full_signature: @Transactional public void addHistoricalRates(List<Quote> quotes)
focal_method.identifier: addHistoricalRates
focal_method.invocations: and and eq getCode eq getCurrency eq getTime exists get findById getCode get findById getCurrency add getPrice getTime saveAll debug size
focal_method.modifiers: @Transactional public
focal_method.parameters: (List<Quote> quotes)
focal_method.return: void
focal_method.signature: void addHistoricalRates(List<Quote> quotes)