@Test public void testResolvePositionForItemNotInDataSet() { final DataSet mockDataSet = mock(DataSet.class); final ItemPositionResolver resolver = new DataSetItemPositionResolver(mockDataSet); when(mockDataSet.getItemCount()).thenReturn(1); when(mockDataSet.getItemId(99)).thenReturn(1L); assertThat(resolver.resolveItemPosition(100), is(ItemPositionResolver.NO_POSITION)); }
@Override public int resolveItemPosition(final long itemId) { final int itemCount = dataSet.getItemCount(); for (int i = 0; i < itemCount; i++) { if (dataSet.getItemId(i) == itemId) return i; } return NO_POSITION; }
DataSetItemPositionResolver implements ItemPositionResolver { @Override public int resolveItemPosition(final long itemId) { final int itemCount = dataSet.getItemCount(); for (int i = 0; i < itemCount; i++) { if (dataSet.getItemId(i) == itemId) return i; } return NO_POSITION; } }
DataSetItemPositionResolver implements ItemPositionResolver { @Override public int resolveItemPosition(final long itemId) { final int itemCount = dataSet.getItemCount(); for (int i = 0; i < itemCount; i++) { if (dataSet.getItemId(i) == itemId) return i; } return NO_POSITION; } DataSetItemPositionResolver(@NonNull final DataSet dataSet); }
DataSetItemPositionResolver implements ItemPositionResolver { @Override public int resolveItemPosition(final long itemId) { final int itemCount = dataSet.getItemCount(); for (int i = 0; i < itemCount; i++) { if (dataSet.getItemId(i) == itemId) return i; } return NO_POSITION; } DataSetItemPositionResolver(@NonNull final DataSet dataSet); @Override int resolveItemPosition(final long itemId); }
DataSetItemPositionResolver implements ItemPositionResolver { @Override public int resolveItemPosition(final long itemId) { final int itemCount = dataSet.getItemCount(); for (int i = 0; i < itemCount; i++) { if (dataSet.getItemId(i) == itemId) return i; } return NO_POSITION; } DataSetItemPositionResolver(@NonNull final DataSet dataSet); @Override int resolveItemPosition(final long itemId);  }