LgoStreamingTradeService implements StreamingTradeService { public Observable<LgoOrderEvent> getRawReceivedOrderEvents() { if (afrSubscription == null) { createAfrSubscription(); } return afrSubscription; } LgoStreamingTradeService(
      LgoStreamingService streamingService,
      LgoKeyService keyService,
      LgoSignatureService signatureService,
      SynchronizedValueFactory<Long> nonceFactory); @Override Observable<Order> getOrderChanges(CurrencyPair currencyPair, Object... args); Observable<OpenOrders> getOpenOrders(CurrencyPair currencyPair); Observable<Collection<Order>> getOrderBatchChanges(CurrencyPair currencyPair); @Override Observable<UserTrade> getUserTrades(CurrencyPair currencyPair, Object... args); Observable<LgoOrderEvent> getRawAllOrderEvents(Collection<CurrencyPair> currencyPairs); Observable<LgoOrderEvent> getRawReceivedOrderEvents(); Observable<LgoOrderEvent> getRawBatchOrderEvents(CurrencyPair currencyPair); String placeMarketOrder(MarketOrder marketOrder); String placeLimitOrder(LimitOrder limitOrder); boolean cancelOrder(String orderId);  }
@Test public void it_handles_orders_ack() throws IOException, ParseException { JsonNode snapshot = TestUtils.getJsonContent("/trade/afr-snapshot.json"); JsonNode update1 = TestUtils.getJsonContent("/trade/afr-update1.json"); JsonNode update2 = TestUtils.getJsonContent("/trade/afr-update2.json"); when(streamingService.subscribeChannel(anyString())) .thenReturn(Observable.just(snapshot, update1, update2)); Observable<LgoOrderEvent> events = service.getRawReceivedOrderEvents(); verify(streamingService).subscribeChannel("afr"); Date date1 = dateFormat.parse("2019-07-24T13:42:34.970Z"); Date date2 = dateFormat.parse("2019-07-24T13:42:35.698Z"); ArrayList<LgoOrderEvent> lgoOrderEvents = Lists.newArrayList(events.blockingIterable()); assertThat(lgoOrderEvents.get(0)) .isEqualToComparingFieldByField( new LgoReceivedOrderEvent("156397575497000001", "plop", "received", date1)); assertThat(lgoOrderEvents.get(1)) .isEqualToComparingFieldByField( new LgoFailedOrderEvent( "156397575497000001", "plop", "failed", date2, "INVALID_PAYLOAD")); }