@Test public void testGetOrder() { OrderDto expectedOrder = mock(OrderDto.class); when(getOrderDto.mapTo()).thenReturn(expectedOrder); when(restTemplate.exchange( requestCaptor.capture(), eq(HttpMethod.GET), entity.capture(), eq(HitbtcOrderGetDto.class) )).thenReturn(new ResponseEntity<>(getOrderDto, HttpStatus.OK)); Optional<OrderDto> result = hitbtcRestService.get(ID); assertThat(result.isPresent()).isTrue(); assertThat(result.get()).isEqualTo(expectedOrder); assertThat(requestCaptor.getValue()).isEqualTo(BASE + "/order/" + ID); }
@Override public Optional<OrderDto> get(String id) { try { return getOpenOrderById(id); } catch (HttpClientErrorException ex) { if (ex.getStatusCode() != HttpStatus.BAD_REQUEST) { throw ex; } return getClosedOrderById(id); } }
HitbtcRestService implements ManageOrders, Withdraw, Account { @Override public Optional<OrderDto> get(String id) { try { return getOpenOrderById(id); } catch (HttpClientErrorException ex) { if (ex.getStatusCode() != HttpStatus.BAD_REQUEST) { throw ex; } return getClosedOrderById(id); } } }
HitbtcRestService implements ManageOrders, Withdraw, Account { @Override public Optional<OrderDto> get(String id) { try { return getOpenOrderById(id); } catch (HttpClientErrorException ex) { if (ex.getStatusCode() != HttpStatus.BAD_REQUEST) { throw ex; } return getClosedOrderById(id); } }  }
HitbtcRestService implements ManageOrders, Withdraw, Account { @Override public Optional<OrderDto> get(String id) { try { return getOpenOrderById(id); } catch (HttpClientErrorException ex) { if (ex.getStatusCode() != HttpStatus.BAD_REQUEST) { throw ex; } return getClosedOrderById(id); } }  @Override Optional<OrderDto> get(String id); @Override List<OrderDto> getOpen(TradingCurrency from, TradingCurrency to); @Override void cancel(String id); @Override Map<TradingCurrency, BigDecimal> balances(); @SneakyThrows @Override void withdraw(TradingCurrency currency, BigDecimal amount, String destination); @Override @IgnoreRateLimited String name(); }
HitbtcRestService implements ManageOrders, Withdraw, Account { @Override public Optional<OrderDto> get(String id) { try { return getOpenOrderById(id); } catch (HttpClientErrorException ex) { if (ex.getStatusCode() != HttpStatus.BAD_REQUEST) { throw ex; } return getClosedOrderById(id); } }  @Override Optional<OrderDto> get(String id); @Override List<OrderDto> getOpen(TradingCurrency from, TradingCurrency to); @Override void cancel(String id); @Override Map<TradingCurrency, BigDecimal> balances(); @SneakyThrows @Override void withdraw(TradingCurrency currency, BigDecimal amount, String destination); @Override @IgnoreRateLimited String name();  }