TimelineDelegate { public void setItemById(T item) { for (int i = 0; i < itemList.size(); i++) { if (item.getId() == itemList.get(i).getId()) { itemList.set(i, item); } } notifyDataSetChanged(); } TimelineDelegate(Timeline<T> timeline);   TimelineDelegate(Timeline<T> timeline, DataSetObservable observable, List<T> items); void refresh(Callback<TimelineResult<T>> developerCb); void next(Callback<TimelineResult<T>> developerCb); void previous(); int getCount(); Timeline getTimeline(); T getItem(int position); long getItemId(int position); void setItemById(T item); void registerDataSetObserver(DataSetObserver observer); void unregisterDataSetObserver(DataSetObserver observer); void notifyDataSetChanged(); void notifyDataSetInvalidated();  }
@Test public void testSetItemById() { delegate = new TimelineDelegate<>(mockTimeline, mockObservable, testItems); assertEquals(TEST_ITEM_2, delegate.getItem(0)); assertEquals(TEST_ITEM_1, delegate.getItem(1)); final TestItem differentItemSameId = new TestItem(TEST_ITEM_2.getId()); delegate.setItemById(differentItemSameId); assertThat(TEST_ITEM_2, not(delegate.getItem(0))); assertEquals(differentItemSameId, delegate.getItem(0)); assertEquals(TEST_ITEM_1, delegate.getItem(1)); verify(mockObservable).notifyChanged(); }