### Question:
HitbtcWsService extends BaseWsClient implements CreateOrder { @Override @SneakyThrows public Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to, BigDecimal amount, BigDecimal price) { PairSymbol pair = cfg.pairFromCurrencyOrThrow(from, to); BigDecimal calcAmount = DefaultInvertHandler.amountFromOrig(pair, amount, price); BigDecimal calcPrice = DefaultInvertHandler.priceFromOrig(pair, price); String side = DefaultInvertHandler.amountToBuyOrSell(calcAmount); ObjectWebSocketSender sender = rxConnected.get().sender(); HitbtcCreateRequestDto requestDto = new HitbtcCreateRequestDto(tryToAssignId, pair.getSymbol(), side, calcPrice, calcAmount.abs()); log.info("Sent WS request {} to {}", requestDto, name()); RxMoreObservables .sendObjectMessage(sender, requestDto) .subscribe(); return Optional.empty(); } HitbtcWsService(HitbtcConfig cfg); @Override @SneakyThrows Optional<OrderCreatedDto> create(String tryToAssignId, TradingCurrency from, TradingCurrency to,
                                            BigDecimal amount, BigDecimal price); @Override String name();  }### Answer:
@Test public void testCreate() { Optional<OrderCreatedDto> id = hitbtcWsService.create("", from, to, amount, price); HitbtcCreateRequestDto request = messageCaptor.getValue(); HitbtcCreateRequestDto.OrderBody params = request.getParams(); assertThat(request.getMethod()).isEqualTo("newOrder"); assertThat(params.getSide()).isEqualTo("buy"); assertThat(params.getPrice()).isEqualTo(price); assertThat(params.getQuantity()).isEqualTo(amount); }
@Test public void testInvertedCreate() { Optional<OrderCreatedDto> id = hitbtcWsService.create("", to, from, amount, price); HitbtcCreateRequestDto request = messageCaptor.getValue(); HitbtcCreateRequestDto.OrderBody params = request.getParams(); assertThat(request.getMethod()).isEqualTo("newOrder"); assertThat(params.getSide()).isEqualTo("sell"); assertThat(params.getPrice()).isEqualTo(BigDecimal.ONE.divide(price, 1, RoundingMode.HALF_EVEN)); assertThat(params.getQuantity()).isEqualTo(amount.negate().multiply(price).abs()); }