@Test public void restore() { when( sessionStorage.read() ).thenReturn( createMemento( FIRST_ITEM, SECOND_ITEM, FIRST_ITEM ) ); Timeline<FakeItem> actual = new Timeline<>( itemProvider, sessionStorage ); assertThat( actual.getItems() ).containsExactly( SECOND_ITEM, FIRST_ITEM ); assertThat( actual.getTopItem() ).contains( FIRST_ITEM ); }
private void restore() { Memento<T> memento = sessionStorage.read(); if( !memento.getItems().isEmpty() ) { addSorted( new ArrayList<>( memento.getItems() ) ); setTopItem( memento.getTopItem().get() ); } }
Timeline { private void restore() { Memento<T> memento = sessionStorage.read(); if( !memento.getItems().isEmpty() ) { addSorted( new ArrayList<>( memento.getItems() ) ); setTopItem( memento.getTopItem().get() ); } } }
Timeline { private void restore() { Memento<T> memento = sessionStorage.read(); if( !memento.getItems().isEmpty() ) { addSorted( new ArrayList<>( memento.getItems() ) ); setTopItem( memento.getTopItem().get() ); } } Timeline( ItemProvider<T> itemProvider, SessionStorage<T> sessionStorage ); }
Timeline { private void restore() { Memento<T> memento = sessionStorage.read(); if( !memento.getItems().isEmpty() ) { addSorted( new ArrayList<>( memento.getItems() ) ); setTopItem( memento.getTopItem().get() ); } } 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(); }
Timeline { private void restore() { Memento<T> memento = sessionStorage.read(); if( !memento.getItems().isEmpty() ) { addSorted( new ArrayList<>( memento.getItems() ) ); setTopItem( memento.getTopItem().get() ); } } 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; }