public void testGetAllStories() throws Exception { List<Story> stories = new ArrayList<Story>(); for (int i = 0; i < 5; i++) { Story story = createStory(i); stories.add(story); boolean result = es.publishStory(story, null); assertTrue(es.getErrorMessage(), result); } // Give elasticsearch some time, its a bit slow. In the head. Thread.sleep(4000); List<Story> result = es.getStories(0, 10); for (Story s : stories) { es.deleteStory(s.getId()); } for (Story s : stories) { assertTrue("Story missing from results", result.contains(s)); } for (Story s : result) { assertEquals(s.getId(), s.getThumbnail().getId()); assertNotNull(s.getThumbnail().getEncodedBitmap()); } }