PackCompleteOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) { synchronized (OrderEventHandler.syncMonitor) { transition(orderEvent, orderEvent.getCustomerOrder(), orderEvent.getCustomerOrderDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY); return true; } }  @Override boolean handle(final OrderEvent orderEvent);  }
@Test public void testHandleStandardOnlineAuth() throws Exception { String label = assertPgFeatures("testPaymentGateway", false, true, true, true); CustomerOrder customerOrder = createTestOrder(TestOrderType.STANDARD, label, false); assertInventory(WAREHOUSE_ID, "CC_TEST1", "7.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_PACKING); CustomerOrderDelivery delivery = null; for (final CustomerOrderDelivery orderDelivery : customerOrder.getDelivery()) { if (CustomerOrderDelivery.DELIVERY_STATUS_PACKING.equals(orderDelivery.getDeliveryStatus())) { assertNull(delivery); delivery = orderDelivery; } } assertTrue(handler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP))); assertInventory(WAREHOUSE_ID, "CC_TEST1", "7.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY); assertSinglePaymentEntry(customerOrder.getOrdernum(), "689.74", PaymentGateway.AUTH, Payment.PAYMENT_STATUS_OK, false); assertEquals("689.74", customerOrder.getOrderTotal().toPlainString()); assertEquals("0.00", paymentService.getOrderAmount(customerOrder.getOrdernum()).toPlainString()); assertEquals(CustomerOrder.ORDER_STATUS_IN_PROGRESS, customerOrder.getOrderStatus()); }
@Test public void testHandleStandardOnlineCapture() throws Exception { configureTestPG(false, true); String label = assertPgFeatures("testPaymentGateway", false, true, false, true); CustomerOrder customerOrder = createTestOrder(TestOrderType.STANDARD, label, false); assertInventory(WAREHOUSE_ID, "CC_TEST1", "7.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_PACKING); CustomerOrderDelivery delivery = null; for (final CustomerOrderDelivery orderDelivery : customerOrder.getDelivery()) { if (CustomerOrderDelivery.DELIVERY_STATUS_PACKING.equals(orderDelivery.getDeliveryStatus())) { assertNull(delivery); delivery = orderDelivery; } } assertTrue(handler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP))); assertInventory(WAREHOUSE_ID, "CC_TEST1", "7.00", "0.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "0.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_SHIPMENT_READY); assertSinglePaymentEntry(customerOrder.getOrdernum(), "689.74", PaymentGateway.AUTH_CAPTURE, Payment.PAYMENT_STATUS_OK, true); assertEquals("689.74", customerOrder.getOrderTotal().toPlainString()); assertEquals("689.74", paymentService.getOrderAmount(customerOrder.getOrdernum()).toPlainString()); assertEquals(CustomerOrder.ORDER_STATUS_IN_PROGRESS, customerOrder.getOrderStatus()); }