CustomerOrderServiceImpl extends BaseGenericServiceImpl<CustomerOrder> implements CustomerOrderService { @Override public CustomerOrder findByGuid(final String shoppingCartGuid) { return getGenericDao().findSingleByCriteria( " where e.cartGuid = ?1", shoppingCartGuid ); } CustomerOrderServiceImpl(final GenericDAO<CustomerOrder, Long> customerOrderDao,
                                    final GenericDAO<Customer, Long> customerDao,
                                    final GenericDAO<Object, Long> genericDao,
                                    final GenericDAO<CustomerOrderDelivery, Long> customerOrderDeliveryDao,
                                    final OrderNumberGenerator orderNumberGenerator,
                                    final OrderAssembler orderAssembler,
                                    final DeliveryAssembler deliveryAssembler,
                                    final OrderSplittingStrategy orderSplittingStrategy,
                                    final CartContentsValidator cartContentsValidator); @Override CustomerOrderDelivery findDelivery(final long deliveryId); @Override CustomerOrderDelivery findDeliveryByNumber(final String deliveryNum); @Override List<Long> findEligibleForExportOrderIds(); @Override int findAwaitingDeliveriesCount(final Set<Long> shops, final String deliveryStatus, final List<String> orderStatus); @Override List<Long> findAwaitingDeliveriesIds(final List<String> skuCodes, final String deliveryStatus, final List<String> orderStatus); @Override ResultsIterator<CustomerOrderDelivery> findAwaitingDeliveries(final List<String> skuCodes, final String deliveryStatus, final List<String> orderStatus); @Override List<CustomerOrder> findOrders(final int start,
                                          final int offset,
                                          final String sort,
                                          final boolean sortDescending,
                                          final Map<String, List> filter); @Override int findOrderCount(final Map<String, List> filter); @Override List<Long> findCustomerOrderIdsByDeliveryIds(final Collection<Long> deliveryIds); @Override List<CustomerOrder> findCustomerOrders(final long customerId, final LocalDateTime since); @Override List<CustomerOrder> findCustomerOrders(final Customer customer, final LocalDateTime since); @Override Map<String, Boolean> isOrderMultipleDeliveriesAllowed(final ShoppingCart shoppingCart); @Override CartValidityModel validateCart(final ShoppingCart shoppingCart); @Override CustomerOrder createFromCart(final ShoppingCart shoppingCart); @Override CustomerOrder findByReference(final String reference); @Override CustomerOrder findByDeliveryReference(final String reference); @Override CustomerOrder findByGuid(final String shoppingCartGuid); @Override CustomerOrder findByOrderNumber(final String orderNumber); @Override void delete(final CustomerOrder instance);  }
@Test public void testFindByGuid() throws Exception { Customer customer = createCustomer(); assertFalse(customer.getAddress().isEmpty()); ShoppingCart shoppingCart = getShoppingCart(true); CustomerOrder order = customerOrderService.createFromCart(shoppingCart); long pk = order.getCustomerorderId(); assertTrue(pk > 0); CustomerOrder order2 = customerOrderService.findByReference(shoppingCart.getGuid()); assertNotNull(order2); customerOrderService.delete(order); assertNull(customerOrderService.findById(pk)); assertNull(customerOrderService.findByReference(shoppingCart.getGuid())); assertNull(customerOrderService.findByReference(null)); }