MainPresenter { public void loadData() { try { String s = mainService.doSomething(); view.showText(s); } catch (Exception e) { snackBarManager.showMessage(e.getMessage()); } } MainPresenter(MainService mainService, MainView view, SnackBarManager snackBarManager); void loadData();  }
@Test public void testLoadData() { when(restService.executeServerCall()).thenReturn(true); presenter.loadData(); verify(view).showText("Hello world"); verify(snackBarManager, never()).showMessage(anyString()); }
@Test public void testErrorOnLoadData() { when(restService.executeServerCall()).thenReturn(false); presenter.loadData(); verify(view, never()).showText(anyString()); verify(snackBarManager).showMessage("Error!"); }