@Test public void orderEventsArePassedThrough() { cut.sendOrder(someOrder, someEventListener); verify(broker).sendOrder(eq(someOrder), receivedOrderEventListener.capture()); receivedOrderEventListener.getValue().orderOpened(Instant.EPOCH.plusMillis(823), new Price(1337)); verify(someEventListener).orderOpened(Instant.EPOCH.plusMillis(823), new Price(1337)); receivedOrderEventListener.getValue().orderClosed(Instant.EPOCH.plusMillis(1234), new Price(42)); verify(someEventListener).orderClosed(Instant.EPOCH.plusMillis(1234), new Price(42)); final OrderManagement sendOrder = cut.sendOrder(someOrder, someEventListener); sendOrder.changeCloseConditionsOfOrder(someCloseConditions); verify(someOrderManagement).changeCloseConditionsOfOrder(someCloseConditions); sendOrder.closeOrCancelOrder(); verify(someOrderManagement).closeOrCancelOrder(); }
@Override public OrderManagement sendOrder(final BasicPendingOrder order, final OrderEventListener eventListener) { if (tradeUnblocker != null) { eventListener.orderRejected(FAILED); return NO_OP_ORDER_MANAGEMENT; } this.tradeUnblocker = new TradeUnblocker(eventListener); final OrderManagement originalOrderManagement = broker.sendOrder(order, tradeUnblocker); if (tradeUnblocker == null) { return NO_OP_ORDER_MANAGEMENT; } else { tradeUnblocker.setOrderManagement(originalOrderManagement); return tradeUnblocker; } }
SingleTradeBroker implements Broker<BasicPendingOrder> { @Override public OrderManagement sendOrder(final BasicPendingOrder order, final OrderEventListener eventListener) { if (tradeUnblocker != null) { eventListener.orderRejected(FAILED); return NO_OP_ORDER_MANAGEMENT; } this.tradeUnblocker = new TradeUnblocker(eventListener); final OrderManagement originalOrderManagement = broker.sendOrder(order, tradeUnblocker); if (tradeUnblocker == null) { return NO_OP_ORDER_MANAGEMENT; } else { tradeUnblocker.setOrderManagement(originalOrderManagement); return tradeUnblocker; } } }
SingleTradeBroker implements Broker<BasicPendingOrder> { @Override public OrderManagement sendOrder(final BasicPendingOrder order, final OrderEventListener eventListener) { if (tradeUnblocker != null) { eventListener.orderRejected(FAILED); return NO_OP_ORDER_MANAGEMENT; } this.tradeUnblocker = new TradeUnblocker(eventListener); final OrderManagement originalOrderManagement = broker.sendOrder(order, tradeUnblocker); if (tradeUnblocker == null) { return NO_OP_ORDER_MANAGEMENT; } else { tradeUnblocker.setOrderManagement(originalOrderManagement); return tradeUnblocker; } } SingleTradeBroker(final Broker<BasicPendingOrder> broker); }
SingleTradeBroker implements Broker<BasicPendingOrder> { @Override public OrderManagement sendOrder(final BasicPendingOrder order, final OrderEventListener eventListener) { if (tradeUnblocker != null) { eventListener.orderRejected(FAILED); return NO_OP_ORDER_MANAGEMENT; } this.tradeUnblocker = new TradeUnblocker(eventListener); final OrderManagement originalOrderManagement = broker.sendOrder(order, tradeUnblocker); if (tradeUnblocker == null) { return NO_OP_ORDER_MANAGEMENT; } else { tradeUnblocker.setOrderManagement(originalOrderManagement); return tradeUnblocker; } } SingleTradeBroker(final Broker<BasicPendingOrder> broker); @Override OrderManagement sendOrder(final BasicPendingOrder order,
            final OrderEventListener eventListener); }
SingleTradeBroker implements Broker<BasicPendingOrder> { @Override public OrderManagement sendOrder(final BasicPendingOrder order, final OrderEventListener eventListener) { if (tradeUnblocker != null) { eventListener.orderRejected(FAILED); return NO_OP_ORDER_MANAGEMENT; } this.tradeUnblocker = new TradeUnblocker(eventListener); final OrderManagement originalOrderManagement = broker.sendOrder(order, tradeUnblocker); if (tradeUnblocker == null) { return NO_OP_ORDER_MANAGEMENT; } else { tradeUnblocker.setOrderManagement(originalOrderManagement); return tradeUnblocker; } } SingleTradeBroker(final Broker<BasicPendingOrder> broker); @Override OrderManagement sendOrder(final BasicPendingOrder order,
            final OrderEventListener eventListener);  }