RateService { public Instant getNewestRateDate(String fromcur, String tocur) { HistoricalRate r = historicalRateRepository.findFirstByFromcurCodeAndTocurCode(fromcur, tocur, SORT_DESC_DATE); return (r == null) ? null : r.getDate(); }  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);  }
@Test public void testGetNewestRateDate() { Instant result = rateService.getNewestRateDate(USD, EUR); assertThat(result).isEqualTo(parse("2015-02-02T08:42:50")); }
@Test public void testGetNewestRateDate_NoElement() { assertThat(rateService.getNewestRateDate(USD, "TOTO")).isNull(); }