BPIServiceClient { public Observable<BPI> getCurrentUSDPrice() { return bpiService.currentPrice().map(new Func1<PriceDto, BPI>() { @Override public BPI call(PriceDto priceDto) { return new BPI(priceDto.getTime().getUpdatedISO(), priceDto.getBpi().get("USD").getRate()); } }); } BPIServiceClient(BPIService bpiService); Observable<BPI> getCurrentUSDPrice(); Observable<List<BPI>> getHistory();  }
@Test public void getCurrentUSDPrice_oneNext() throws ParseException { Date date = newDate(1); float rate = 2.3456f; BPIService service = mock(BPIService.class); when(service.currentPrice()).thenReturn(Observable.from(new PriceDto[]{ newUSDPrice(date, rate) })); BPIServiceClient client = new BPIServiceClient(service); TestSubscriber<BPI> subscriber = new TestSubscriber<>(); client.getCurrentUSDPrice().subscribe(subscriber); List<BPI> expectedResults = Lists.newArrayList( new BPI(date, rate) ); subscriber.assertReceivedOnNext(expectedResults); subscriber.assertTerminalEvent(); subscriber.assertNoErrors(); }