YahooLookup implements LookupProvider { @VisibleForTesting protected static String parseSource(String code) { Matcher forexMatcher = FOREX_PATTERN.matcher(code); if (forexMatcher.matches()) { String source = forexMatcher.group(1); String target = forexMatcher.group(2); return (target != null) ? source : CurrencyUtils.USD; } Matcher cryptoMatcher = CRYPTOCURRENCY_PATTERN.matcher(code); if (cryptoMatcher.matches()) { return cryptoMatcher.group(1); } Matcher stockMatcher = EQUITY_PATTERN.matcher(code); if (stockMatcher.matches()) { return stockMatcher.group(1); } Matcher futureMatcher = FUTURE_PATTERN.matcher(code); if (futureMatcher.matches()) { return futureMatcher.group(1); } return null; }  @Override List<LookupInfo> search(String symbolOrName); @Override LookupDetails getDetails(String code); @Override String getProviderCode();  }
@Test @Parameters public void testParseSource(String code, String expectedResult) { assertThat(YahooLookup.parseSource(code)).isEqualTo(expectedResult); }