ProductCartDao extends HibernateDao<ProductCart, String> { @SuppressWarnings("unchecked") public ProductCart getCartOfUser(final User user) { List<ProductCart> result = (List<ProductCart>) getHibernateTemplate().find("from ProductCart where user=?", user); return (result.isEmpty()) ? null : result.get(0); }  @SuppressWarnings("unchecked") ProductCart getCartOfUser(final User user); void deleteCartOfUser(User user); void deleteProductReferences(final Product product); List<Product> scrollCartOfUser(final User user, final int skip, final int top); List<Long> getProductsIdOfCart(User user);  }
@Test public void getCartOfUser() { User user = udao.read("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3"); ProductCart cart = dao.getCartOfUser(user); assertNotNull(cart); assertEquals(cart.getUUID(), "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1"); assertEquals(cart.getUser(), user, "User not owner of the found cart."); user = udao.read("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1"); cart = dao.getCartOfUser(user); assertNull(cart); user = udao.read("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2"); cart = dao.getCartOfUser(user); assertNotNull(cart); }