@Test public void testHandleStandardInventoryInsufficient() throws Exception { String label = assertPgFeatures("testPaymentGateway", false, true, true, true); CustomerOrder customerOrder = createTestOrder(TestOrderType.STANDARD, label, false); debitInventoryAndAssert(WAREHOUSE_ID, "CC_TEST2", "1.00", "0.00", "1.00"); assertInventory(WAREHOUSE_ID, "CC_TEST1", "9.00", "2.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "1.00"); assertDeliveryStates(customerOrder.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_ALLOCATION_WAIT); CustomerOrderDelivery delivery = null; for (final CustomerOrderDelivery orderDelivery : customerOrder.getDelivery()) { if (CustomerOrderDelivery.DELIVERY_STATUS_ALLOCATION_WAIT.equals(orderDelivery.getDeliveryStatus())) { assertNull(delivery); delivery = orderDelivery; } } try { handler.handle( new OrderEventImpl("", customerOrder, delivery, Collections.EMPTY_MAP)); fail("Should fail as the inventory has depleted"); } catch (OrderItemAllocationException oiae) { } final CustomerOrder orderAfterException = orderService.findByReference(customerOrder.getOrdernum()); assertInventory(WAREHOUSE_ID, "CC_TEST1", "9.00", "2.00"); assertInventory(WAREHOUSE_ID, "CC_TEST2", "0.00", "1.00"); assertDeliveryStates(orderAfterException.getDelivery(), CustomerOrderDelivery.DELIVERY_STATUS_ALLOCATION_WAIT); assertSinglePaymentEntry(orderAfterException.getOrdernum(), "689.74", PaymentGateway.AUTH, Payment.PAYMENT_STATUS_OK, false); assertEquals("689.74", orderAfterException.getOrderTotal().toPlainString()); assertEquals("0.00", paymentService.getOrderAmount(orderAfterException.getOrdernum()).toPlainString()); assertEquals(CustomerOrder.ORDER_STATUS_IN_PROGRESS, orderAfterException.getOrderStatus()); }
@Override public boolean handle(final OrderEvent orderEvent) throws OrderItemAllocationException { synchronized (OrderEventHandler.syncMonitor) { allocateQuantity(orderEvent, orderEvent.getCustomerOrderDelivery()); return true; } }
ProcessAllocationOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderItemAllocationException { synchronized (OrderEventHandler.syncMonitor) { allocateQuantity(orderEvent, orderEvent.getCustomerOrderDelivery()); return true; } } }
ProcessAllocationOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderItemAllocationException { synchronized (OrderEventHandler.syncMonitor) { allocateQuantity(orderEvent, orderEvent.getCustomerOrderDelivery()); return true; } } ProcessAllocationOrderEventHandlerImpl(final WarehouseService warehouseService,
                                                  final InventoryResolver inventoryResolver,
                                                  final ProductService productService); }
ProcessAllocationOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderItemAllocationException { synchronized (OrderEventHandler.syncMonitor) { allocateQuantity(orderEvent, orderEvent.getCustomerOrderDelivery()); return true; } } ProcessAllocationOrderEventHandlerImpl(final WarehouseService warehouseService,
                                                  final InventoryResolver inventoryResolver,
                                                  final ProductService productService); @Override boolean handle(final OrderEvent orderEvent); }
ProcessAllocationOrderEventHandlerImpl extends AbstractEventHandlerImpl implements OrderEventHandler { @Override public boolean handle(final OrderEvent orderEvent) throws OrderItemAllocationException { synchronized (OrderEventHandler.syncMonitor) { allocateQuantity(orderEvent, orderEvent.getCustomerOrderDelivery()); return true; } } ProcessAllocationOrderEventHandlerImpl(final WarehouseService warehouseService,
                                                  final InventoryResolver inventoryResolver,
                                                  final ProductService productService); @Override boolean handle(final OrderEvent orderEvent);  }