Hi there. I have the following test: ``` privat...
# test
u
Hi there. I have the following test:
Copy code
private var interceptSelectedRoute = mock<InterceptSelectedRoute>()
@Captor
val interceptSelectedRouteCaptor = argumentCaptor<DisposableObserver<DetailedRoute>>()
Copy code
@Test
    fun `when selected route is intercepted, we should start persisting it`() {

        doNothing().`when`(interceptSelectedRoute).dispose()

        interactor.start()

        val selectedRoute = NavigatorRouteFactory.makeDetailedRoute()

        verify(interceptSelectedRoute).execute(interceptSelectedRouteCaptor.capture(), eq(null))

        interceptSelectedRouteCaptor.firstValue.onNext(selectedRoute)

        assertEquals(
                expected = NavigatorStateMachine.State.Initialization.PersistingRoute(selectedRoute),
                actual = interactor.stateMachine.state
        )
    }
Inside
interactor
there is this method invocation:
Copy code
private fun stopInterceptingSelectedRoute() {
        interceptSelectedRoute.dispose()
   }
interceptSelectedRoute
is a child of the following class:
Copy code
abstract class ObservableUseCase<T, in Params> constructor(
        private val postExecutionThread: PostExecutionThread
) {

    val subscriptions = CompositeDisposable()

    abstract fun buildUseCaseObservable(params: Params? = null): Observable<T>

    open fun execute(observer: DisposableObserver<T>, params: Params? = null) {
        val observable = this.buildUseCaseObservable(params)
                .subscribeOn(<http://Schedulers.io|Schedulers.io>())
                .observeOn(postExecutionThread.scheduler)

        observable.subscribeWith(observer).disposedBy(subscriptions)
    }

    fun dispose() {
        subscriptions.clear()
    }

}
When
stopInterceptingSelectedRoute()
is invoked, I get
NullPointerException
because
subscriptions == null
. I don't understand why
doNothing()
does not work here as expected (meaning that the real method is not invoked). Could you help?