UserPresenter extends BasePresenter<User, UserView> { public void setUser(User user) { setModel(user); } UserPresenter(); void setUser(User user);  }
@Test public void testSetUser() { User user = mUserList.get(0); UserPresenter userPresenter = new UserPresenter(); userPresenter.setUser(user); userPresenter.bindView(mUserViewMock); Mockito.verifyZeroInteractions(mUserViewMock); userPresenter.onViewReady(); Mockito.verify(mUserViewMock, Mockito.times(1)).showPhoto(user.getPhoto(), StringUtils.getUserInitials(user)); Mockito.verify(mUserViewMock, Mockito.times(1)).showName(StringUtils.getUserName(user)); Mockito.verify(mUserViewMock, Mockito.times(1)).hideRecordsCount(); }
@Test public void testSetUser2() { User user = mUserList.get(0); user.setRecordsCount(7); user.setEnabledRecordsCount(4); UserPresenter userPresenter = new UserPresenter(); userPresenter.setUser(user); userPresenter.bindView(mUserViewMock); Mockito.verifyZeroInteractions(mUserViewMock); userPresenter.onViewReady(); Mockito.verify(mUserViewMock, Mockito.times(1)).showPhoto(user.getPhoto(), StringUtils.getUserInitials(user)); Mockito.verify(mUserViewMock, Mockito.times(1)).showName(StringUtils.getUserName(user)); Mockito.verify(mUserViewMock, Mockito.times(1)).showRecordsCount(7, 4); }
@Test public void testOnViewNotReady() { User user = mUserList.get(0); UserPresenter userPresenter = new UserPresenter(); userPresenter.setUser(user); userPresenter.bindView(mUserViewMock); Mockito.verifyZeroInteractions(mUserViewMock); userPresenter.onViewReady(); userPresenter.onViewNotReady(); Mockito.verify(mUserViewMock, Mockito.times(1)).showPhoto(user.getPhoto(), StringUtils.getUserInitials(user)); }