EnterDeckSourceLanguagePresenter { public void newSourceLanguageSelected(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { String selectedLanguage = data.getStringExtra(LanguageSelectorActivity.SELECTED_LANGUAGE_KEY); if (selectedLanguage != null) { newDeckContext.setSourceLanguage(selectedLanguage); activity.updateSourceLanguage(selectedLanguage); } } } EnterDeckSourceLanguagePresenter(EnterDeckSourceLanguageView activity, NewDeckContext newDeckContext); void inflateBitmaps(); void newSourceLanguageSelected(int resultCode, Intent data); void initSourceLanguage(); void nextButtonClicked(); void backButtonClicked(); void sourceLanguageClicked();  }
@Test public void shouldUpdateSourceLanguageWhenNewSourceLanguageIsSelected() { Intent intent = mock(Intent.class); String selectedLanguage = "A Language"; when(intent.getStringExtra(LanguageSelectorActivity.SELECTED_LANGUAGE_KEY)).thenReturn(selectedLanguage); presenter.newSourceLanguageSelected(Activity.RESULT_OK, intent); verify(newDeckContext).setSourceLanguage(selectedLanguage); verify(activity).updateSourceLanguage(selectedLanguage); }
@Test public void shouldNotUpdateSourceLanguageWhenNoNewSourceLanguageIsSelected() { presenter.newSourceLanguageSelected(Activity.RESULT_CANCELED, mock(Intent.class)); verifyZeroInteractions(newDeckContext); verifyZeroInteractions(activity); }