Here is my test method where It should be success if showLoading() and loadDataSuccess(response) was called:
@RunWith(PowerMockRunner.class)
public class PresenterTest {
@Mock
private ProfileContract.View view;
@Mock
private ProfileContract.Handler handler;
@Test
public void onLoadDataClicked() {
presenter.loadData();
verify(mView, times(1)).showLoading();
verify(mHandler, times(1)).loadDataSuccess();
}
}
UPDATE 1 Here is my presenter:
class ProfilePresenter(private val mView: ProfileContract.View) : ProfileContract.Handler {
override fun loadData() {
mView.showLoading()
mUserService.user()
.compose(RxUtil.mapper())
.subscribe({ response ->
loadDataSuccess()
}, { error ->
//stuff
})
}
}
Thanks!