如何使用Spring 5反应堆WebFlux检查单元测试中的步骤?
我正在从命令式模式迁移到反应式模式,我很难以反应式的方式测试我的mock回调。例如,在服务类中是否可以检查是否调用了mock如何使用Spring 5反应堆WebFlux检查单元测试中的步骤?,spring,reactive-programming,spring-webflux,Spring,Reactive Programming,Spring Webflux,我正在从命令式模式迁移到反应式模式,我很难以反应式的方式测试我的mock回调。例如,在服务类中是否可以检查是否调用了mock TransactionId transactionId = authorizerApplicationService.newPaymentAuthorization( new PaymentTransactionCommand( OPERATION_ID, TAX_ID
TransactionId transactionId = authorizerApplicationService.newPaymentAuthorization(
new PaymentTransactionCommand(
OPERATION_ID,
TAX_ID));
final ArgumentCaptor<Transaction> argumentsTransaction = ArgumentCaptor.forClass(Transaction.class);
verify(repository, times(2)).save(argumentsTransaction.capture());
final Transaction transaction = argumentsTransaction.getValue();
verify(iamServicePort).authenticate(...));
verify(antiFraudServicePort).checkCustomerSituation(...);
verify(paymentGatewayServicePort, times(0)).authorize(...);
assertEquals(transactionId, transaction.transactionId());
assertEquals(Money.of(100, "BRL"), transaction.amount());
考虑到我所有的外部服务都返回Void,我如何进行呼叫验证
StepVerifier.create(authorizerApplicationService.newPaymentAuthorization(
new PaymentTransactionCommand(
OPERATION_ID,
TAX_ID)))
.expectNext(OPERATION_ID)
//I need to check here if the mocks were invoked
.verifyComplete();