YahooStockProvider implements LatestRateProvider, HistoricalRateProvider { @Override public Quote getLatestRate(String symbol) { YahooModel result = rt.getForObject(format(url, symbol), YahooModel.class); return result .getQuoteResponse().getResult().stream().map(yf -> new Quote(yf.getSymbol(), BigDecimal.valueOf(yf.getRegularMarketPrice()), toInstant(yf.getRegularMarketTime()))) .findFirst().orElse(null); }  @Override List<Quote> getRates(); @Override Quote getLatestRate(String symbol); @Override List<Quote> getHistoricalRates(); @Override List<Quote> getHistoricalRates(String code);  }
@Test public void testGetLatestRate() { server.expect(anything()).andRespond(withSuccess(LATEST_UBI, MediaType.APPLICATION_JSON)); Quote result = yahooStock.getLatestRate("UBI.PA"); assertThat(result).isEqualTo(new Quote("UBI.PA", null, new BigDecimal("57.52"), parse("2017-09-08T17:35:14+02:00"))); }