@Test public void shouldSendPendingOrdersCorrectly() throws CommunicationException { final OrderManagement result = cut.sendOrder(EXAMPLE_PENDING_ORDER, exampleOrderEventListener); verify(client).sendMessage(sentMessage.capture()); assertThat(sentMessage.getValue()).isInstanceOf(PlacePendingOrderMessage.class); final PlacePendingOrderMessage sentMessage = (PlacePendingOrderMessage) this.sentMessage.getValue(); assertThat(sentMessage.getPendingOrder()).isEqualTo(EXAMPLE_PENDING_ORDER); assertThat(result).isNotNull(); }
@Override public OrderManagement sendOrder(final PendingOrder order, final OrderEventListener eventListener) { try { clientConnection.sendMessage(new PlacePendingOrderMessage(order)); final ResponsePlacePendingOrderMessage idMessage = clientConnection .readMessage(ResponsePlacePendingOrderMessage.class); if (idMessage.isSuccess()) { orderMapper.put(idMessage.getId().get(), eventListener); return new RemoteOrderManagement(idMessage.getId().get()); } else { eventListener.orderRejected(new MetaTraderFailure(idMessage.getErrorCode().get())); return NO_OP_ORDER_MANAGEMENT; } } catch (final CommunicationException e) { throw new LoopThroughCommunicationException(e); } }
RemoteBroker implements Broker<PendingOrder> { @Override public OrderManagement sendOrder(final PendingOrder order, final OrderEventListener eventListener) { try { clientConnection.sendMessage(new PlacePendingOrderMessage(order)); final ResponsePlacePendingOrderMessage idMessage = clientConnection .readMessage(ResponsePlacePendingOrderMessage.class); if (idMessage.isSuccess()) { orderMapper.put(idMessage.getId().get(), eventListener); return new RemoteOrderManagement(idMessage.getId().get()); } else { eventListener.orderRejected(new MetaTraderFailure(idMessage.getErrorCode().get())); return NO_OP_ORDER_MANAGEMENT; } } catch (final CommunicationException e) { throw new LoopThroughCommunicationException(e); } } }
RemoteBroker implements Broker<PendingOrder> { @Override public OrderManagement sendOrder(final PendingOrder order, final OrderEventListener eventListener) { try { clientConnection.sendMessage(new PlacePendingOrderMessage(order)); final ResponsePlacePendingOrderMessage idMessage = clientConnection .readMessage(ResponsePlacePendingOrderMessage.class); if (idMessage.isSuccess()) { orderMapper.put(idMessage.getId().get(), eventListener); return new RemoteOrderManagement(idMessage.getId().get()); } else { eventListener.orderRejected(new MetaTraderFailure(idMessage.getErrorCode().get())); return NO_OP_ORDER_MANAGEMENT; } } catch (final CommunicationException e) { throw new LoopThroughCommunicationException(e); } } RemoteBroker(final MessageBasedClientConnection clientConnection, final PendingOrderMapper orderMapper); }
RemoteBroker implements Broker<PendingOrder> { @Override public OrderManagement sendOrder(final PendingOrder order, final OrderEventListener eventListener) { try { clientConnection.sendMessage(new PlacePendingOrderMessage(order)); final ResponsePlacePendingOrderMessage idMessage = clientConnection .readMessage(ResponsePlacePendingOrderMessage.class); if (idMessage.isSuccess()) { orderMapper.put(idMessage.getId().get(), eventListener); return new RemoteOrderManagement(idMessage.getId().get()); } else { eventListener.orderRejected(new MetaTraderFailure(idMessage.getErrorCode().get())); return NO_OP_ORDER_MANAGEMENT; } } catch (final CommunicationException e) { throw new LoopThroughCommunicationException(e); } } RemoteBroker(final MessageBasedClientConnection clientConnection, final PendingOrderMapper orderMapper); @Override OrderManagement sendOrder(final PendingOrder order, final OrderEventListener eventListener); }
RemoteBroker implements Broker<PendingOrder> { @Override public OrderManagement sendOrder(final PendingOrder order, final OrderEventListener eventListener) { try { clientConnection.sendMessage(new PlacePendingOrderMessage(order)); final ResponsePlacePendingOrderMessage idMessage = clientConnection .readMessage(ResponsePlacePendingOrderMessage.class); if (idMessage.isSuccess()) { orderMapper.put(idMessage.getId().get(), eventListener); return new RemoteOrderManagement(idMessage.getId().get()); } else { eventListener.orderRejected(new MetaTraderFailure(idMessage.getErrorCode().get())); return NO_OP_ORDER_MANAGEMENT; } } catch (final CommunicationException e) { throw new LoopThroughCommunicationException(e); } } RemoteBroker(final MessageBasedClientConnection clientConnection, final PendingOrderMapper orderMapper); @Override OrderManagement sendOrder(final PendingOrder order, final OrderEventListener eventListener);  }