From 3bd0801360a12c6a92f3774f4c926e10074bb5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Pitu=C5=82a?= Date: Tue, 16 Apr 2024 09:05:13 +0200 Subject: [PATCH] Test cancelling during checks --- .../example/WithdrawalWorkflowTest.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/workflow4s-example/src/test/scala/workflow4s/example/WithdrawalWorkflowTest.scala b/workflow4s-example/src/test/scala/workflow4s/example/WithdrawalWorkflowTest.scala index 527dabc..059d006 100644 --- a/workflow4s-example/src/test/scala/workflow4s/example/WithdrawalWorkflowTest.scala +++ b/workflow4s-example/src/test/scala/workflow4s/example/WithdrawalWorkflowTest.scala @@ -13,6 +13,7 @@ import workflow4s.example.testuitls.TestUtils.SimpleSignalResponseOps import workflow4s.wio.model.{WIOModel, WIOModelInterpreter} import workflow4s.wio.simple.{InMemoryJournal, SimpleActor} import io.circe.syntax.* +import org.scalatest.Inside.inside import workflow4s.example.checks.StaticCheck import workflow4s.example.withdrawal.checks.{Check, CheckResult, ChecksEngine, ChecksInput, ChecksState, Decision} import workflow4s.example.withdrawal.{WithdrawalData, WithdrawalEvent, WithdrawalService, WithdrawalSignal, WithdrawalWorkflow} @@ -140,6 +141,23 @@ class WithdrawalWorkflowTest extends AnyFreeSpec with MockFactory { checkRecovery() } + "when running checks" in new Fixture { + val check = StaticCheck(CheckResult.Pending()) + withFeeCalculation(fees) + withMoneyOnHold(success = true) + withChecks(List(check)) + withFundsLockCancelled() + + actor.init(CreateWithdrawal(amount, recipient)) + inside(actor.queryData()) { case data: WithdrawalData.Checking => + assert(data.checkResults.results == Map(check.key -> CheckResult.Pending())) + } + actor.cancel(WithdrawalSignal.CancelWithdrawal("operator-1", "cancelled", acceptStartedExecution = true)) + assert(actor.queryData() == WithdrawalData.Completed.Failed("Cancelled by operator-1. Comment: cancelled")) + + checkRecovery() + } + } }