@Test public void setFetchCount() { int newFetchCount = timeline.getFetchCount() + 1; timeline.setFetchCount(newFetchCount); assertEquals(newFetchCount, timeline.getFetchCount()); }
@Test public void setFetchCountExceedsLowerBound() { int tooSmall = FETCH_COUNT_LOWER_BOUND - 1; Throwable actual = thrownBy(() -> timeline.setFetchCount(tooSmall)); assertNotNull(actual); assertTrue(actual instanceof IllegalArgumentException); assertTrue(actual.getMessage().contains(valueOf(tooSmall))); assertEquals(format(ERROR_EXCEEDS_LOWER_BOUND, tooSmall), actual.getMessage()); }
@Test public void fetchFirstItemsWithoutTopItemToRecover() throws IOException { itemProvider.addItems(FIRST_ITEM, SECOND_ITEM, THIRD_ITEM, FOURTH_ITEM); timeline.setFetchCount(2); timeline.fetchItems(); List<Item> actual = timeline.getItems(); assertArrayEquals(new Item[] {FOURTH_ITEM, THIRD_ITEM}, actual.toArray(new Item[2])); verify(sessionStorage).storeTop(FOURTH_ITEM); }
@Test public void fetchItems() { itemProvider.addItems(FIRST_ITEM, SECOND_ITEM, THIRD_ITEM, FOURTH_ITEM, FIFTH_ITEM, SIXTH_ITEM); timeline.setFetchCount(2); timeline.fetchItems(); timeline.fetchItems(); List<Item> actual = timeline.getItems(); assertArrayEquals( new Item[] {SIXTH_ITEM, FIFTH_ITEM, FOURTH_ITEM, THIRD_ITEM}, actual.toArray(new Item[2])); }