Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.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
Kotlin 在AxonFramework中是否可能期望来自非axon类的dispatch命令_Kotlin_Axon - Fatal编程技术网

Kotlin 在AxonFramework中是否可能期望来自非axon类的dispatch命令

Kotlin 在AxonFramework中是否可能期望来自非axon类的dispatch命令,kotlin,axon,Kotlin,Axon,假设我有一些不是axon类的类(比如Saga或agrgregate),如果我想让它发送命令,我可以使用command gateway,但问题出在这里。我想写作 单元测试以确保此非axon类已调度命令。所以,如果是saga或aggregate,我可以使用fixture,然后给出命令或事件,但是fixture是否也可以与这些非axon类一起使用呢。 下面是代码的样子 class MyService { //... lateinit var commandGateway: Comman

假设我有一些不是axon类的类(比如Saga或agrgregate),如果我想让它发送命令,我可以使用command gateway,但问题出在这里。我想写作 单元测试以确保此非axon类已调度命令。所以,如果是saga或aggregate,我可以使用fixture,然后给出命令或事件,但是fixture是否也可以与这些非axon类一起使用呢。
下面是代码的样子

class MyService {
    //...
    lateinit var commandGateway: CommandGateway
    fun doSomething(command: doSomethingCommand){
        commandGateway.send(command)
    }
}

class MyServiceTest {
    //...
    @Test
    fun doSomething_ShouldDispatchDoSomethingCommand(){
        // expect dispatch command from non axon-class
    }
}

正如您所注意到的,Axon框架为聚合和Sagas提供了测试夹具,而没有指定任何其他选项。
AggregateTestFixture
确实提供了一种方法,即
AggregateTestFixture#registerNotatedCommandHandler
。但是,这是为了验证包含
@CommandHandler
注释方法的组件,而不是验证分派

因此,老实说,我认为最直接的方法是模拟或监视
CommandGateway
/
CommandBus
,以进行验证