MemoryProductStore extends AbstractPositionedEntityMemoryStore<Product, DefaultPositionedEntity<Product>> implements ProductStore { public List<Product> findOrphanProducts() { return FluentIterable.from(all()).filter(new Predicate<Product>() { public boolean apply(@Nullable Product input) { return input.getCollections().isLoaded() && input.getCollections().get().isEmpty(); } }).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 testFindOrphans() throws InvalidEntityException, EntityAlreadyExistsException { Collection collection1 = new Collection(); collection1.setId(UUID.randomUUID()); Collection collection2 = new Collection(); collection2.setId(UUID.randomUUID()); Product product1 = new Product(); product1.setCollections(Arrays.asList(collection1)); Product product2 = new Product(); product2.setCollections(Arrays.asList(collection2)); Product product3 = new Product(); product3.setCollections(new ArrayList<Collection>()); Product product4 = new Product(); product4.setCollections(Arrays.asList(collection1, collection2)); productStore.create(product1); productStore.create(product2); productStore.create(product3); productStore.create(product4); List<Product> orphans = productStore.findOrphanProducts(); Assert.assertEquals(1, orphans.size()); Assert.assertEquals(product3, orphans.get(0)); }