rook
05/15/2017, 6:04 PMonBind
disposables.add(dao.subscribeToVehicle(Consumer { updateView() }))
In writing tests around this object, I’m mocking dao
using Mockito, which then requires me to stub the subscribeToVehicle(consumer: Consumer<Boolean>)
so that it doesn’t return null
. However, when I stub the method call
Mockito.`when`(dao.subscribeToVehicle(any())).thenReturn(mock(Disposable::class.java))
Since any()
returns null
, it fails at runtime with java.lang.IllegalStateException: any() must not be null
. Am I doing something wrong? It feels like this isn’t a problem with Spek or Kotlin, but I’ve scoured all the solutions related to this in Java and tangentially related in Kotlin, but nothing seems to fix my problem.
This link looked like it was a solution to my problem, but the solution isn’t working and the only difference is that I’m using Spek: http://stackoverflow.com/a/30308199/981242
Any help would be greatly appreciated.