CardListAdapter extends ArrayAdapter<Translation> { public void update() { updateTranslationCardStates(); clear(); addAll(translationService.getCurrentTranslations()); notifyDataSetChanged(); } CardListAdapter(Context context, int resource, int textViewResourceId,
                           List<Translation> objects, TranslationService translationService,
                           DictionaryService dictionaryService, DeckService deckService); @Override View getView(int position, View translationItemView, ViewGroup parent); void update();  }
@Test public void shouldNotUpdateTranslationCardStatesWhenListAdapterIsUpdatedWithSameNumberOfTranslations() { when(mockTranslationService.getCurrentTranslations()).thenReturn(translations); cardListAdapter.update(); verify(mockTranslationService, times(0)).initializeCardStates(); }
@Test public void shouldUpdateTranslationCardStatesWhenListAdapterIsUpdatedWithDifferentNumberOfTranslations() { List<Translation> longerTranslations = Arrays.asList(firstTranslation, secondTranslation); when(mockTranslationService.getCurrentTranslations()).thenReturn(longerTranslations); cardListAdapter.update(); verify(mockTranslationService).initializeCardStates(); }