ProductCartService extends WebService { @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(propagation = Propagation.REQUIRED) public void clearCart(String uuid) throws UserNotExistingException { ProductCart cart = getCartOfUser(uuid); if ((cart != null) && (cart.getProducts() != null)) { cart.getProducts().clear(); productCartDao.update(cart); } }  @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = false, propagation = Propagation.REQUIRED) ProductCart createCartOfUser(String uuid); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = false, propagation = Propagation.REQUIRED) ProductCart createCartOfUser(User user); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = false, propagation = Propagation.REQUIRED) void deleteCartOfUser(String uuid); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = true, propagation = Propagation.REQUIRED) ProductCart getCartOfUser(String uuid); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = true, propagation = Propagation.REQUIRED) ProductCart getCartOfUser(User user); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(propagation = Propagation.REQUIRED) void addProductToCart(String uuid, Long p_id); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(propagation = Propagation.REQUIRED) void removeProductFromCart(String uuid, Long p_id); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(propagation = Propagation.REQUIRED) List<Long> getProductsIdOfCart(String uuid); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = true, propagation = Propagation.REQUIRED) List<Product> getProductsOfCart(String uuid, int skip, int top); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = true, propagation = Propagation.REQUIRED) int countProductsInCart(String uuid); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = true) int countProducts(CartSQLVisitor visitor, String uuid); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = true) List<Product> getCartProducts(CartSQLVisitor visitor, String uuid, int skip, int top); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(readOnly = true, propagation = Propagation.REQUIRED) boolean hasProducts(String uuid); @PreAuthorize("hasRole('ROLE_DOWNLOAD')") @Transactional(propagation = Propagation.REQUIRED) void clearCart(String uuid);  }
@Test (priority=100) public void clearCart() { try { pcs.clearCart("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1000"); Assert.fail("System remove cart of an unknown user ?"); } catch (Exception e) { } try { pcs.clearCart("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3"); } catch (Exception e) { Assert.fail("Cannot remove single cart of existing user.", e); } try { pcs.clearCart("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1"); } catch (Exception e) { Assert.fail("Cannot remove empty cart of existing user.", e); } try { pcs.clearCart("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2"); } catch (Exception e) { Assert.fail("Cannot remove multi-cart of existing user.", e); } }