MemoryArticleStore extends BaseEntityMemoryStore<Article> implements ArticleStore { @Override public List<Article> findAllPublished(Integer offset, Integer number) { Iterable<Article> allPublished = FluentIterable.from(all()).filter(new Predicate<Article>() { public boolean apply(@Nullable Article input) { return input.getPublished() != null && input.getPublished(); } }); if (number == 0) { return FluentIterable.from(allPublished).skip(offset).toList(); } return FluentIterable.from(allPublished).skip(offset).limit(number).toList(); }  Article findBySlug(String slug); @Override List<Article> findAllPublished(Integer offset, Integer number); @Override Integer countAllPublished();  }
@Test public void testFindAllPublished() throws InvalidEntityException, EntityAlreadyExistsException { Article article1 = new Article(); article1.setPublished(true); article1 = articleStore.create(article1); Article article2 = new Article(); article2.setPublished(false); article2 = articleStore.create(article2); Article article3 = new Article(); article3 = articleStore.create(article3); Article article4 = new Article(); article4.setPublished(true); article4 = articleStore.create(article4); Assert.assertEquals(new Integer(2), articleStore.countAllPublished()); Assert.assertTrue(articleStore.findAllPublished(0, 0).contains(article1)); Assert.assertTrue(articleStore.findAllPublished(0, 0).contains(article4)); }