MemoryProductStore extends AbstractPositionedEntityMemoryStore<Product, DefaultPositionedEntity<Product>> implements ProductStore { public void updateStock(UUID productId, Integer stockOffset) throws EntityDoesNotExistException { Product product = this.findById(productId); product.setStock(product.getStock() + stockOffset); }  void moveProduct(String productToMove, String productToMoveRelativeTo,
            RelativePosition relativePosition); void updatePosition(Integer position, Product product); List<Product> findOrphanProducts(); Integer countAllForCollection(Collection collection); List<Product> findForCollection(Collection collection, Integer number, Integer offset); @Override List<Product> findOnShelfForCollection(final Collection collection, Integer number, Integer offset); List<Product> findAllForCollection(final Collection collection); List<Product> findAllOnShelf(Integer number, Integer offset); Integer countAllOnShelf(); List<Product> findAllNotVariants(Integer number, Integer offset); Integer countAllNotVariants(); List<Product> findAllWithTitleLike(String title, Integer number, Integer offset); Integer countAllWithTitleLike(String title); void updateStock(UUID productId, Integer stockOffset); List<Feature> findFeatures(Product product); List<Feature> findFeatures(Product product, String feature); Feature findFeature(Product product, String feature, String featureSlug); List<Product> findVariants(Product product); Product findVariant(Product product, String variantSlug); Feature createFeature(Feature feature); List<Product> findAllForCollection(EntityAndParent<Collection> collection);  }
@Test public void testUpdateStock() throws EntityDoesNotExistException, InvalidEntityException, EntityAlreadyExistsException { Product product = new Product(); product.setOnShelf(true); product.setStock(100); product = productStore.create(product); productStore.updateStock(product.getId(), -20); Assert.assertEquals(new Integer(80), productStore.findById(product.getId()).getStock()); productStore.updateStock(product.getId(), +50); Assert.assertEquals(new Integer(130), productStore.findById(product.getId()).getStock()); }