@Test public void setTopItem() { itemProvider.addItems( FIRST_ITEM, SECOND_ITEM ); timeline.fetchItems(); timeline.setTopItem( FIRST_ITEM ); assertThat( timeline.getTopItem() ).contains( FIRST_ITEM ); assertThat( captureStorageMemento( SECOND_STORAGE_CALL ) ) .isEqualTo( createMemento( FIRST_ITEM, SECOND_ITEM, FIRST_ITEM ) ); }
public void setTopItem( T topItem ) { checkArgument( topItem != null, ERROR_TOP_ITEM_MUST_NOT_BE_NULL ); checkArgument( items.contains( topItem ), ERROR_TOP_ITEM_IS_UNRELATED, topItem.getId() ); this.topItem = Optional.of( topItem ); sessionStorage.store( createMemento() ); }
Timeline { public void setTopItem( T topItem ) { checkArgument( topItem != null, ERROR_TOP_ITEM_MUST_NOT_BE_NULL ); checkArgument( items.contains( topItem ), ERROR_TOP_ITEM_IS_UNRELATED, topItem.getId() ); this.topItem = Optional.of( topItem ); sessionStorage.store( createMemento() ); } }
Timeline { public void setTopItem( T topItem ) { checkArgument( topItem != null, ERROR_TOP_ITEM_MUST_NOT_BE_NULL ); checkArgument( items.contains( topItem ), ERROR_TOP_ITEM_IS_UNRELATED, topItem.getId() ); this.topItem = Optional.of( topItem ); sessionStorage.store( createMemento() ); } Timeline( ItemProvider<T> itemProvider, SessionStorage<T> sessionStorage ); }
Timeline { public void setTopItem( T topItem ) { checkArgument( topItem != null, ERROR_TOP_ITEM_MUST_NOT_BE_NULL ); checkArgument( items.contains( topItem ), ERROR_TOP_ITEM_IS_UNRELATED, topItem.getId() ); this.topItem = Optional.of( topItem ); 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(); }
Timeline { public void setTopItem( T topItem ) { checkArgument( topItem != null, ERROR_TOP_ITEM_MUST_NOT_BE_NULL ); checkArgument( items.contains( topItem ), ERROR_TOP_ITEM_IS_UNRELATED, topItem.getId() ); this.topItem = Optional.of( topItem ); 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; }