LgoStreamingTradeService implements StreamingTradeService { public String placeLimitOrder(LimitOrder limitOrder) throws IOException { Long ref = nonceFactory.createValue(); LgoPlaceOrder lgoOrder = LgoAdapters.adaptLimitOrder(limitOrder); return placeOrder(ref, lgoOrder); } 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_places_a_limit_order() throws IOException, ParseException { Date date = dateFormat.parse("2019-07-25T07:16:21.600Z"); LimitOrder limitOrder = new LimitOrder( Order.OrderType.ASK, new BigDecimal("0.5"), CurrencyPair.BTC_USD, null, date, new BigDecimal("12000")); when(nonceFactory.createValue()).thenReturn(22L); LgoKey key = new LgoKey( "abcdefg", new Date().toInstant().minus(1, ChronoUnit.HOURS), new Date().toInstant().plus(1, ChronoUnit.HOURS)); InputStream stream = LgoStreamingExchangeExample.class.getResourceAsStream("/public.pem"); String utf8 = IOUtils.toString(stream, StandardCharsets.UTF_8); key.setValue(parsePublicKey(utf8)); when(keyService.selectKey()).thenReturn(key); when(signatureService.signOrder(anyString())).thenReturn(new LgoOrderSignature("signed")); doNothing().when(streamingService).sendMessage(anyString()); String ref = service.placeLimitOrder(limitOrder); verify(nonceFactory).createValue(); verify(keyService).selectKey(); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(streamingService).sendMessage(captor.capture()); assertThat(captor.getValue().contains("\"reference\":22")); assertThat( captor .getValue() .contains( "\"signature\":{\"value\":\"signed\",\"source\":\"RSA\"},\"key_id\":\"abcdefg\"},\"type\":\"placeorder\"")); assertThat(ref).isEqualTo("22"); }