-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Description
Hi,
I have implemented the same architecture in kotlin but when I'm mocking a UseCase class, it's not initializing, my presenter test class is below:
private var presenter:SetAddressPresenter? = null
@Mock
private var mockContext: Context? = null
@Mock
private var controller: Controller? = null
@Mock
private lateinit var setAddressUseCase: SetAddressUseCase
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
presenter = SetAddressPresenter(setAddressUseCase)
presenter?.setAddressController(controller)
}
@Test
fun testUserListPresenterInitialize() {
given(controller?.context()).willReturn(mockContext)
presenter?.loadPreviousAddresses()
verify(controller)?.hideRetry()
verify(controller)?.showLoading()
verify(setAddressUseCase)?.execute(
any(SetAddressPresenter.SetAddressObserver::class.java),
any(Void::class.java) )
}
Getting the NullPointerException on
...domain.interactor.UseCase.execute(UseCase.kt:53)
my UseCase Class is:
..........
init {
compositeDisposable = CompositeDisposable()
this.threadExecutor = threadExecutor
this.postExecutionThread = postExecutionThread
}
fun execute(observer: DisposableObserver<T>, params: Any?) {
val observable = this.buildUseCaseObservable(params)
.subscribeOn(Schedulers.from(threadExecutor)) // Line no 53
.observeOn(postExecutionThread.getScheduler())
addDisposable(observable.subscribeWith(observer))
}
..........
Could you please help or advice on this?
Metadata
Metadata
Assignees
Labels
No labels