Skip to content

Instantly share code, notes, and snippets.

@ragdroid
Last active March 10, 2017 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ragdroid/1c955ff24966710206c3a8791fcd8730 to your computer and use it in GitHub Desktop.
Save ragdroid/1c955ff24966710206c3a8791fcd8730 to your computer and use it in GitHub Desktop.
@Mock MainView mainViewMock;
@Mock PokeDataSource pokeDataSource;
@Mock HttpException httpException;
@Test
public void testDemoResponseError404() {
reset(mainViewMock);
MainPresenterImpl presenter = new MainPresenterImpl(schedulersProvider, pokeDataSource);
when(httpException.code()).thenReturn(HttpURLConnection.HTTP_NOT_FOUND);
when(pokeDataSource.getPokemonAbilityStringObservable(anyString()))
.thenReturn(Observable.<String>error(httpException));
presenter.onViewAdded(mainViewMock, null);
testScheduler.triggerActions();
verify(mainViewMock, times(1)).showErrorDialog("Lost!");
verify(mainViewMock, times(0)).setApiText(anyString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment