fix(domain): correlate withdrawal by process instance to the subscribed execution (refs #12)
All checks were successful
CI / lint (pull_request) Successful in 1m15s
CI / build (pull_request) Successful in 1m1s
CI / unit (pull_request) Successful in 1m20s
CI / frontend (pull_request) Successful in 2m50s
CI / mutation (pull_request) Successful in 5m22s
CI / verify-stack (pull_request) Successful in 7m18s
All checks were successful
CI / lint (pull_request) Successful in 1m15s
CI / build (pull_request) Successful in 1m1s
CI / unit (pull_request) Successful in 1m20s
CI / frontend (pull_request) Successful in 2m50s
CI / mutation (pull_request) Successful in 5m22s
CI / verify-stack (pull_request) Successful in 7m18s
verify-stack surfaced a Flowable 500: delivering messageEventReceived to the Beoordelen task's execution is wrong — a message boundary event's subscription lives on its own execution. Correlate instead by the registration's process instance id (recorded at submit): query the execution subscribed to RegistratieIngetrokken and deliver the message there. Withdrawal moves from IUserTaskClient to IWorkflowClient.WithdrawProcessAsync; the handler no longer needs a task lookup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,15 +5,20 @@ namespace Big.Tests;
|
||||
|
||||
public class WithdrawRegistrationTests
|
||||
{
|
||||
private static FakeUserTaskClient NoTasks() => new([]);
|
||||
private static Registration Submitted(string processInstanceId = "proc-1")
|
||||
{
|
||||
var registration = Registration.Submit("123456782");
|
||||
registration.RecordProcessStarted(processInstanceId);
|
||||
return registration;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Withdrawing_marks_the_registration_ingetrokken_and_persists_it()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
var registration = Submitted();
|
||||
store.Seed(registration);
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
var handler = new WithdrawRegistration(store, new FakeWorkflowClient());
|
||||
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
|
||||
@@ -23,43 +28,42 @@ public class WithdrawRegistrationTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Withdrawing_cancels_the_open_beoordelen_task_via_its_execution()
|
||||
public async Task Withdrawing_cancels_the_running_process()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
var registration = Submitted("proc-42");
|
||||
store.Seed(registration);
|
||||
var tasks = new FakeUserTaskClient([new BeoordelingTask("task-1", "exec-1", registration.Id)]);
|
||||
var handler = new WithdrawRegistration(store, tasks);
|
||||
var workflow = new FakeWorkflowClient();
|
||||
var handler = new WithdrawRegistration(store, workflow);
|
||||
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
|
||||
// The withdrawal message is delivered to the Beoordelen task's execution, tripping the
|
||||
// boundary event that ends the process (ADR-0014).
|
||||
Assert.Equal("exec-1", tasks.WithdrawnExecutionId);
|
||||
// The process the registration recorded at submit is cancelled (ADR-0014).
|
||||
Assert.Equal("proc-42", workflow.WithdrawnProcessInstanceId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Withdrawing_with_no_open_task_still_marks_ingetrokken()
|
||||
public async Task Withdrawing_before_a_process_was_started_still_marks_ingetrokken()
|
||||
{
|
||||
// If the process has not parked at Beoordelen yet (or already ended), the withdrawal stands:
|
||||
// the aggregate is INGETROKKEN and nothing is cancelled.
|
||||
// A registration with no recorded process (e.g. start never happened) can still be withdrawn;
|
||||
// there is simply no process to cancel.
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
var registration = Registration.Submit("123456782"); // no RecordProcessStarted
|
||||
store.Seed(registration);
|
||||
var tasks = NoTasks();
|
||||
var handler = new WithdrawRegistration(store, tasks);
|
||||
var workflow = new FakeWorkflowClient();
|
||||
var handler = new WithdrawRegistration(store, workflow);
|
||||
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
|
||||
Assert.Equal(RegistrationStatus.Ingetrokken, (await store.GetAsync(registration.Id))!.Status);
|
||||
Assert.Null(tasks.WithdrawnExecutionId);
|
||||
Assert.Null(workflow.WithdrawnProcessInstanceId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Rejects_a_null_command_without_touching_the_store()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
var handler = new WithdrawRegistration(store, new FakeWorkflowClient());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
|
||||
Assert.Equal(0, store.SaveCount);
|
||||
@@ -69,7 +73,7 @@ public class WithdrawRegistrationTests
|
||||
public async Task Withdrawing_an_unknown_registration_throws()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
var handler = new WithdrawRegistration(store, new FakeWorkflowClient());
|
||||
|
||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
||||
() => handler.HandleAsync(new WithdrawRegistrationCommand(RegistrationId.New())));
|
||||
@@ -81,9 +85,10 @@ public class WithdrawRegistrationTests
|
||||
public async Task Re_withdrawing_an_already_ingetrokken_registration_is_idempotent()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
var registration = Submitted();
|
||||
store.Seed(registration);
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
var workflow = new FakeWorkflowClient();
|
||||
var handler = new WithdrawRegistration(store, workflow);
|
||||
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
|
||||
Reference in New Issue
Block a user