Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何解析-指定为非null的参数为null_Java_Android_Kotlin_Junit_Kotlin Coroutines - Fatal编程技术网

Java 如何解析-指定为非null的参数为null

Java 如何解析-指定为非null的参数为null,java,android,kotlin,junit,kotlin-coroutines,Java,Android,Kotlin,Junit,Kotlin Coroutines,我有一个单元测试,在这个单元测试中,我试图检查是否使用正确的参数调用了用例,但我得到了一个错误 java.lang.IllegalArgumentException:指定为非null的参数为null:method com.xx.xxx.clean.orderview.domain.onstanduceCaseCoroutine$Params.,参数serviceType @Test fun `when notifyOnStand is called then we create a Timest

我有一个单元测试,在这个单元测试中,我试图检查是否使用正确的参数调用了用例,但我得到了一个错误

java.lang.IllegalArgumentException:指定为非null的参数为null:method com.xx.xxx.clean.orderview.domain.onstanduceCaseCoroutine$Params.,参数serviceType

@Test
fun `when notifyOnStand is called then we create a TimestampedAction with the correct user id, vehicle, timestamp and pass that to the usecase`() {
    val actionCaptor = argumentCaptor<TimestampedAction>()
    val timestamp = DateTime.now()

    every(noServiceRequiredBus.get()).thenReturn(Observable.just(REQUESTED))
    every(timingsUpdater.timestampCalculator(any(), any())).thenReturn(timestamp)

    baseOrderViewPresenter.setView(view)
    baseOrderViewPresenter.notifyOnStand()

    runBlocking {
        verify(onStandUseCaseCoroutine).run(OnStandUseCaseCoroutine.Params(any(), any(), capture(actionCaptor)))
    }
}
具有用例调用的Presenter层

private fun onstandUseCaseCoroutines(serviceType: String, id: String, action: TimestampedAction, callback: (GenericResponse?) -> Unit) {
    try {
        onStandUseCaseCoroutine(OnStandUseCaseCoroutine.Params(serviceType, id, action)) {
            callback.invoke(it)
        }
    } catch (exception: Exception) {
        onStandResponseErrors()
    }
}
请问我该怎么修

我尝试更改为下面的代码,但没有解决它,我不确定如何执行
捕获(actionCaptor)
位,如果这是问题所在

 runBlocking {
        verify(onStandUseCaseCoroutine).run(OnStandUseCaseCoroutine.Params(anyString(), anyString(), capture(actionCaptor)))
    }
有什么建议吗

谢谢
R

问题源于将空值传递给serviceType字符串参数。尽量不要用任何..隐藏代码。。任何方法以便我们能够找到原因我,当我从
any()
更改为
anyString()
时,
serviceType
id
以及
capture(actionCaptor)
的错误消失了,我不知道怎么做,就像我没有
anyString
@RustamSamandarov谢谢你的回应,你在用mockito吗?
 runBlocking {
        verify(onStandUseCaseCoroutine).run(OnStandUseCaseCoroutine.Params(anyString(), anyString(), capture(actionCaptor)))
    }