test_class.declarator: LATEST = readFile("/provider/rate/yahoo/latest_currencies.json")
test_class.modifier: private static final
test_class.original_string: private static final String LATEST = readFile("/provider/rate/yahoo/latest_currencies.json");
test_class.type: String
test_class.var_name: LATEST
test_class.declarator: server
test_class.modifier: private
test_class.original_string: private MockRestServiceServer server;
test_class.type: MockRestServiceServer
test_class.var_name: server
test_class.declarator: yahooCurrencyProvider = new YahooCurrencyProvider()
test_class.modifier: private
test_class.original_string: private YahooCurrencyProvider yahooCurrencyProvider = new YahooCurrencyProvider();
test_class.type: YahooCurrencyProvider
test_class.var_name: yahooCurrencyProvider
test_class.file: trading-common/src/test/java/fr/ymanvieu/trading/common/provider/rate/yahoo/YahooCurrencyProviderTest.java
test_class.identifier: YahooCurrencyProviderTest
test_case.body: @Test
  	public void testGetRates() throws Exception {
  		server.expect(anything()).andRespond(withSuccess(LATEST, MediaType.APPLICATION_JSON));
  
  		Quote expectedUsdEurRate = new Quote(USD, EUR, new BigDecimal("0.8322"), parse("2017-09-11T10:01:00+02:00"));
  
  		List<Quote> result = yahooCurrencyProvider.getRates();
  
  		assertThat(result).containsOnlyOnce(expectedUsdEurRate);
  	}
test_case.class_method_signature: YahooCurrencyProviderTest.testGetRates()
test_case.full_signature: @Test public void testGetRates()
test_case.identifier: testGetRates
test_case.invocations: andRespond expect anything withSuccess parse getRates containsOnlyOnce assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetRates()
focal_class.declarator: FOREX_PATTERN = Pattern.compile("(\\w{3})(\\w{3})?=X")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern FOREX_PATTERN = Pattern.compile("(\\w{3})(\\w{3})?=X");
focal_class.type: Pattern
focal_class.var_name: FOREX_PATTERN
focal_class.declarator: url
focal_class.modifier: @Value("${provider.yahoo.url.latest.currencies}")
  	private
focal_class.original_string: @Value("${provider.yahoo.url.latest.currencies}")
  	private String url;
focal_class.type: String
focal_class.var_name: url
focal_class.declarator: rt = new RestTemplate()
focal_class.modifier: private final
focal_class.original_string: private final RestTemplate rt = new RestTemplate();
focal_class.type: RestTemplate
focal_class.var_name: rt
focal_class.file: trading-common/src/main/java/fr/ymanvieu/trading/common/provider/rate/yahoo/YahooCurrencyProvider.java
focal_class.identifier: YahooCurrencyProvider
focal_class.interfaces: implements LatestRateProvider
focal_class.class_method_signature: YahooCurrencyProvider.getRates()
focal_class.full_signature: @Override public List<Quote> getRates()
focal_class.identifier: getRates
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<Quote>
focal_class.signature: List<Quote> getRates()
focal_method.body: @Override
  	public List<Quote> getRates() throws IOException {
  		YahooModel result = rt.getForObject(url, YahooModel.class);
  
  		return result.getQuoteResponse().getResult().stream()
  				.map(yf -> {
  					Matcher m = FOREX_PATTERN.matcher(yf.getSymbol());
  
  					m.matches();
  					String source = m.group(1);
  					String target = m.group(2);
  
  					if (target == null) {
  						target = source;
  						source = CurrencyUtils.USD;
  					}
  
  					Instant inst = Instant.ofEpochSecond(yf.getRegularMarketTime());
  					
  					return new Quote(source, target, BigDecimal.valueOf(yf.getRegularMarketPrice()), inst);
  				})
  				.collect(Collectors.toList());
  	}
focal_method.class_method_signature: YahooCurrencyProvider.getRates()
focal_method.full_signature: @Override public List<Quote> getRates()
focal_method.identifier: getRates
focal_method.invocations: getForObject collect map stream getResult getQuoteResponse matcher getSymbol matches group group ofEpochSecond getRegularMarketTime valueOf getRegularMarketPrice toList
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: List<Quote>
focal_method.signature: List<Quote> getRates()