OERMarketDataService extends OERMarketDataServiceRaw implements MarketDataService { @Override public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException { OERRates rates = getOERTicker(currencyPair); Method method = null; try { method = OERRates.class.getMethod("get" + currencyPair.counter.getCurrencyCode(), null); } catch (SecurityException | NoSuchMethodException e) { throw new ExchangeException("Problem getting exchange rate!", e); } Double exchangeRate = null; try { exchangeRate = (Double) method.invoke(rates, null); } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { throw new ExchangeException("Problem getting exchange rate!", e); } return OERAdapters.adaptTicker(currencyPair, exchangeRate); } OERMarketDataService(Exchange exchange); @Override Ticker getTicker(CurrencyPair currencyPair, Object... args); @Override OrderBook getOrderBook(CurrencyPair currencyPair, Object... args); @Override Trades getTrades(CurrencyPair currencyPair, Object... args);  }
@Test public void testTakesCorrectValueFromOERRates() throws IOException { Exchange exchange = ExchangeFactory.INSTANCE.createExchange(OERExchange.class); OERMarketDataService marketDataService = new OERMarketDataService(exchange) { @Override public OERRates getOERTicker(CurrencyPair pair) { assertThat(pair.base).isEqualTo(Currency.USD); OERRates r = new OERRates(); r.setAUD(1.23d); return r; } }; Ticker t = marketDataService.getTicker(CurrencyPair.USD_AUD); assertThat(t.getCurrencyPair()).isEqualTo(CurrencyPair.USD_AUD); assertThat(t.getLast()).isEqualTo(BigDecimal.valueOf(1.23d)); }