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: @Test
  	public void testGetLatest_Direct() {
  
  		Rate result = rateService.getLatest(USD, GBP);
  
  		assertThat(result.getFromcur().getCode()).isEqualTo(USD);
  		assertThat(result.getTocur().getCode()).isEqualTo(GBP);
  		assertThat(result.getValue()).isEqualByComparingTo("0.664982");
  		assertThat(result.getDate()).isEqualTo(parse("2015-02-02T08:42:50"));
  	}
test_case.class_method_signature: RateServiceTest.testGetLatest_Direct()
test_case.full_signature: @Test public void testGetLatest_Direct()
test_case.identifier: testGetLatest_Direct
test_case.invocations: getLatest isEqualTo assertThat getCode getFromcur isEqualTo assertThat getCode getTocur isEqualByComparingTo assertThat getValue isEqualTo assertThat getDate parse
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetLatest_Direct()
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: public Rate getLatest(String fromcur, String tocur) {
  		
  		LatestRate lr = latestRateRepository.findByFromcurCodeAndTocurCode(fromcur, tocur);
  
  		if (lr != null) {
  			return rateMapper.mapToRate(lr);
  		}
  
  		LatestRate lrBaseCurrency = latestRateRepository.findByFromcurCodeAndTocurCode(BASE_CURRENCY, tocur);
  
  		LatestRate lrBaseCurrencyFromcur = latestRateRepository.findByFromcurCodeAndTocurCode(BASE_CURRENCY, fromcur);
  
  		final BigDecimal rate;
  		final SymbolEntity symbolFromcur;
  		final SymbolEntity symbolTocur;
  
  		Instant rateDate = lrBaseCurrencyFromcur.getDate();
  
  		if (BASE_CURRENCY.equals(tocur)) {
  			rate = MathUtils.invert(lrBaseCurrencyFromcur.getValue());
  			symbolFromcur = lrBaseCurrencyFromcur.getTocur();
  			symbolTocur = lrBaseCurrencyFromcur.getFromcur();
  		} else {
  			rate = MathUtils.divide(lrBaseCurrency.getValue(), lrBaseCurrencyFromcur.getValue());
  
  			if (rateDate.isBefore(lrBaseCurrency.getDate())) {
  				rateDate = lrBaseCurrency.getDate();
  			}
  
  			symbolFromcur = lrBaseCurrencyFromcur.getTocur();
  			symbolTocur = lrBaseCurrency.getTocur();
  		}
  
  		return rateMapper.mapToRate(new LatestRate(symbolFromcur, symbolTocur, rate, rateDate));
  	}
focal_method.class_method_signature: RateService.getLatest(String fromcur, String tocur)
focal_method.full_signature: public Rate getLatest(String fromcur, String tocur)
focal_method.identifier: getLatest
focal_method.invocations: findByFromcurCodeAndTocurCode mapToRate findByFromcurCodeAndTocurCode findByFromcurCodeAndTocurCode getDate equals invert getValue getTocur getFromcur divide getValue getValue isBefore getDate getDate getTocur getTocur mapToRate
focal_method.modifiers: public
focal_method.parameters: (String fromcur, String tocur)
focal_method.return: Rate
focal_method.signature: Rate getLatest(String fromcur, String tocur)