BTCMarketsTradeService extends BTCMarketsTradeServiceRaw implements TradeService { @Override public boolean cancelOrder(String orderId) throws IOException, BTCMarketsException { return cancelBTCMarketsOrder(Long.parseLong(orderId)).getSuccess(); } BTCMarketsTradeService(Exchange exchange); @Override String placeMarketOrder(MarketOrder order); @Override String placeLimitOrder(LimitOrder order); @Override OpenOrders getOpenOrders(); @Override OpenOrders getOpenOrders(OpenOrdersParams params); @Override boolean cancelOrder(String orderId); @Override boolean cancelOrder(CancelOrderParams orderParams); @Override UserTrades getTradeHistory(TradeHistoryParams params); @Override Collection<Order> getOrder(OrderQueryParams... orderQueryParams); @Override HistoryParams createTradeHistoryParams(); @Override OpenOrdersParams createOpenOrdersParams();  }
@Test public void shouldCancelOrder() throws IOException { BTCMarketsCancelOrderRequest cancelOrderRequest = new BTCMarketsCancelOrderRequest(111L); BTCMarketsCancelOrderResponse orderResponse = new BTCMarketsCancelOrderResponse( true, null, 0, Arrays.asList(new BTCMarketsException(true, null, 0, "12345", 111L, null))); BTCMarketsAuthenticated btcm = mock(BTCMarketsAuthenticated.class); PowerMockito.when( btcm.cancelOrder( Mockito.eq(SPECIFICATION_API_KEY), Mockito.any(SynchronizedValueFactory.class), Mockito.any(BTCMarketsDigest.class), Mockito.refEq(cancelOrderRequest))) .thenReturn(orderResponse); Whitebox.setInternalState(marketsTradeService, "btcm", btcm); boolean cancelled = marketsTradeService.cancelOrder("111"); assertThat(cancelled).isTrue(); }