@Test public void testResolveItemPosition() { final DataSet mockDataSet = mock(DataSet.class); final ItemPositionResolver resolver = new DataSetItemPositionResolver(mockDataSet); when(mockDataSet.getItemCount()).thenReturn(10); for (int i = 0; i < mockDataSet.getItemCount(); i++) { when(mockDataSet.getItemId(i)).thenReturn(i + 2L); assertThat(resolver.resolveItemPosition(i + 2L), is(i)); verify(mockDataSet).getItemId(i); } }
@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);  }