If I invoke one time addArticle() method then the cart is not empty but cart.getArticles().get(book) always return null even if the cart contains some entries. When I got this situation i figured out that the problem was the lack of hashCode and equals. Now that the methods are implemented nothing is changed. Moreover i've tried using a hashCode() that return always 1 and equals() that return always true but currentQuantity is still null.