@Test public void shouldGetFeedForCategoryWhenNoOffsetMarkerIsSet() throws Exception { generateData(66, null); Assert.assertEquals(5, feedGenerator.getFeedForId(1, "Cat-0").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(2, "Cat-0").getEvents().size()); Assert.assertEquals(3, feedGenerator.getFeedForId(7, "Cat-0").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(1, "Cat-1").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(2, "Cat-1").getEvents().size()); Assert.assertEquals(3, feedGenerator.getFeedForId(7, "Cat-1").getEvents().size()); }
@Test public void shouldGetFeedWhenOffsetMarkerIsSet() throws Exception { generateData(66, null); markerService.markEvents(new String[] {"Cat-0", "Cat-1", ""}, 20); Assert.assertEquals(5, feedGenerator.getFeedForId(1, "Cat-0").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(2, "Cat-0").getEvents().size()); Assert.assertEquals(3, feedGenerator.getFeedForId(7, "Cat-0").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(1, "Cat-1").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(2, "Cat-1").getEvents().size()); Assert.assertEquals(3, feedGenerator.getFeedForId(7, "Cat-1").getEvents().size()); }
@Test public void shouldGetFeed() throws Exception { generateData(3, "Cat-0"); generateData(2, "Cat-1"); generateData(13, "Cat-0"); generateData(12, "Cat-1"); Assert.assertEquals(5, feedGenerator.getFeedForId(1, "Cat-1").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(2, "Cat-0").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(2, "Cat-1").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(3, "Cat-0").getEvents().size()); Assert.assertEquals(4, feedGenerator.getFeedForId(3, "Cat-1").getEvents().size()); Assert.assertEquals(1, feedGenerator.getFeedForId(4, "Cat-0").getEvents().size()); }
@Test public void shouldGetFeedWithMultipleChunkingHistoriesWithoutMarkers() throws Exception { generateData(48, "Cat-1"); Assert.assertEquals(5, feedGenerator.getFeedForId(1, "Cat-1").getEvents().size()); Assert.assertEquals(5, feedGenerator.getFeedForId(9, "Cat-1").getEvents().size()); Assert.assertEquals(3, feedGenerator.getRecentFeed("Cat-1").getEvents().size()); addChunkingHistory(9, 49); FeedGenerator newFeedGenerator = new NumberFeedGenerator(allEventRecords, allEventRecordsOffsetMarkers, chunkingEntries); Assert.assertEquals(3, newFeedGenerator.getRecentFeed("Cat-1").getEvents().size()); Assert.assertEquals(3, newFeedGenerator.getFeedForId(10, "Cat-1").getEvents().size()); generateData(49, "Cat-1"); Assert.assertEquals(3, newFeedGenerator.getFeedForId(10, "Cat-1").getEvents().size()); Assert.assertEquals(9, newFeedGenerator.getFeedForId(11, "Cat-1").getEvents().size()); Assert.assertEquals(4, newFeedGenerator.getFeedForId(16, "Cat-1").getEvents().size()); }