Timeline { public void fetchItems() { addSorted( itemProvider.fetchItems( getOldest(), getFetchCount() ) ); updateTopItem(); sessionStorage.store( createMemento() ); } Timeline( ItemProvider<T> itemProvider, SessionStorage<T> sessionStorage ); void setFetchCount( int fetchCount ); int getFetchCount(); Optional<T> getTopItem(); void setTopItem( T topItem ); void fetchItems(); int getNewCount(); void fetchNew(); List<T> getItems(); static final int FETCH_COUNT_LOWER_BOUND; static final int FETCH_COUNT_UPPER_BOUND; static final int DEFAULT_FETCH_COUNT; }
@Test public void fetchItems( FetchItemsData data ) { itemProvider.addItems( data.getInput() ); timeline.setFetchCount( data.getPageSize() ); timeline.fetchItems(); timeline.fetchItems(); List<FakeItem> actual = timeline.getItems(); assertThat( data.getOutput() ).containsExactlyElementsOf( actual ); assertThat( captureStorageMemento( SECOND_STORAGE_CALL ) ).isEqualTo( data.getMemento() ); }