HitbtcStreamingMarketDataService implements StreamingMarketDataService { @Override public Observable<Ticker> getTicker(CurrencyPair currencyPair, Object... args) { String pair = currencyPair.base.toString() + currencyPair.counter.toString(); String channelName = getChannelName("ticker", pair); final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper(); return service .subscribeChannel(channelName) .map(s -> mapper.readValue(s.toString(), HitbtcWebSocketTickerTransaction.class)) .map(s -> HitbtcAdapters.adaptTicker(s.getParams(), currencyPair)); } HitbtcStreamingMarketDataService(HitbtcStreamingService service); @Override Observable<OrderBook> getOrderBook(CurrencyPair currencyPair, Object... args); @Override Observable<Trade> getTrades(CurrencyPair currencyPair, Object... args); @Override Observable<Ticker> getTicker(CurrencyPair currencyPair, Object... args);  }
@Test public void testGetTicker() throws Exception { String tickerString = IOUtils.toString(getClass().getResource("/example/notificationTicker.json"), "UTF8"); when(streamingService.subscribeChannel(eq("ticker-BTCUSD"))) .thenReturn(Observable.just(objectMapper.readTree(tickerString))); Ticker expected = new Ticker.Builder() .currencyPair(CurrencyPair.BTC_USD) .last(new BigDecimal("0.054463")) .bid(new BigDecimal("0.054463")) .ask(new BigDecimal("0.054464")) .high(new BigDecimal("0.057559")) .low(new BigDecimal("0.053615")) .volume(new BigDecimal("33068.346")) .timestamp(new Date(1508427944941L)) .build(); TestObserver<Ticker> test = marketDataService.getTicker(CurrencyPair.BTC_USD).test(); test.assertValue( ticker -> { assertThat(ticker.getAsk()).isEqualTo(expected.getAsk()); assertThat(ticker.getBid()).isEqualTo(expected.getBid()); assertThat(ticker.getHigh()).isEqualTo(expected.getHigh()); assertThat(ticker.getLow()).isEqualTo(expected.getLow()); assertThat(ticker.getLast()).isEqualTo(expected.getLast()); assertThat(ticker.getVolume()).isEqualTo(expected.getVolume()); assertThat(ticker.getTimestamp()).isEqualTo(expected.getTimestamp()); return true; }); }