Kotlin 在AxonFramework中是否可能期望来自非axon类的dispatch命令
假设我有一些不是axon类的类(比如Saga或agrgregate),如果我想让它发送命令,我可以使用command gateway,但问题出在这里。我想写作 单元测试以确保此非axon类已调度命令。所以,如果是saga或aggregate,我可以使用fixture,然后给出命令或事件,但是fixture是否也可以与这些非axon类一起使用呢。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
下面是代码的样子
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
,以进行验证