MemoryProductStore extends AbstractPositionedEntityMemoryStore<Product, DefaultPositionedEntity<Product>> implements ProductStore { public List<Product> findAllOnShelf(Integer number, Integer offset) { if (number == 0) { return FluentIterable.from(all()).filter(ON_SHELF).skip(offset).toList(); } return FluentIterable.from(all()).filter(ON_SHELF).skip(offset).limit(number) .toList(); }  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 testFindAllOnShelf() throws InvalidEntityException, EntityAlreadyExistsException { Product product1 = new Product(); product1.setOnShelf(true); Product product2 = new Product(); Product product3 = new Product(); product3.setOnShelf(false); Product product4 = new Product(); product4.setOnShelf(true); productStore.create(product1); productStore.create(product2); productStore.create(product3); productStore.create(product4); List<Product> onShelf = productStore.findAllOnShelf(0, 0); Assert.assertEquals(2, onShelf.size()); Assert.assertSame(product1, onShelf.get(0)); Assert.assertSame(product4, onShelf.get(1)); onShelf = productStore.findAllOnShelf(1, 0); Assert.assertEquals(1, onShelf.size()); Assert.assertSame(product1, onShelf.get(0)); onShelf = productStore.findAllOnShelf(1, 1); Assert.assertEquals(1, onShelf.size()); Assert.assertSame(product4, onShelf.get(0)); }