YahooLookup implements LookupProvider { @Override public LookupDetails getDetails(String code) throws IOException { List<LookupInfo> result = search(code); LookupInfo cl = result.stream().filter(li -> li.getCode().equals(code)).findFirst().orElse(null); String name = cl.getName(); String source = parseSource(code); String currency = parseTarget(code); if (currency == null) { currency = rt.getForObject(format(urlLatest, code), YahooModel.class).getQuoteResponse().getResult().get(0).getCurrency().toUpperCase(); } return new LookupDetails(code, name, source, currency, cl.getExchange(), getProviderCode()); }  @Override List<LookupInfo> search(String symbolOrName); @Override LookupDetails getDetails(String code); @Override String getProviderCode();  }
@Test public void testGetDetails() throws Exception { server.expect(anything()).andRespond(withSuccess(SEARCH_RESULT, MediaType.APPLICATION_JSON)); server.expect(anything()).andRespond(withSuccess(LATEST_UBI, MediaType.APPLICATION_JSON)); assertThat(yahooLookup.getDetails("UBI.PA").getCurrency()).isEqualTo("EUR"); }