test(domain): withdrawal cancels the workflow via the Beoordelen task's execution (refs #12)
The WithdrawRegistration handler delivers the withdrawal message to the open Beoordelen task's execution; the Workflow Client PUTs messageEventReceived (RegistratieIngetrokken). BeoordelingTask now carries its executionId. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,13 +5,15 @@ namespace Big.Tests;
|
||||
|
||||
public class WithdrawRegistrationTests
|
||||
{
|
||||
private static FakeUserTaskClient NoTasks() => new([]);
|
||||
|
||||
[Fact]
|
||||
public async Task Withdrawing_marks_the_registration_ingetrokken_and_persists_it()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
store.Seed(registration);
|
||||
var handler = new WithdrawRegistration(store);
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
|
||||
@@ -20,11 +22,44 @@ public class WithdrawRegistrationTests
|
||||
Assert.Equal(1, store.SaveCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Withdrawing_cancels_the_open_beoordelen_task_via_its_execution()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
store.Seed(registration);
|
||||
var tasks = new FakeUserTaskClient([new BeoordelingTask("task-1", "exec-1", registration.Id)]);
|
||||
var handler = new WithdrawRegistration(store, tasks);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Withdrawing_with_no_open_task_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.
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
store.Seed(registration);
|
||||
var tasks = NoTasks();
|
||||
var handler = new WithdrawRegistration(store, tasks);
|
||||
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
|
||||
Assert.Equal(RegistrationStatus.Ingetrokken, (await store.GetAsync(registration.Id))!.Status);
|
||||
Assert.Null(tasks.WithdrawnExecutionId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Rejects_a_null_command_without_touching_the_store()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var handler = new WithdrawRegistration(store);
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
|
||||
Assert.Equal(0, store.SaveCount);
|
||||
@@ -34,7 +69,7 @@ public class WithdrawRegistrationTests
|
||||
public async Task Withdrawing_an_unknown_registration_throws()
|
||||
{
|
||||
var store = new FakeRegistrationStore();
|
||||
var handler = new WithdrawRegistration(store);
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
|
||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
||||
() => handler.HandleAsync(new WithdrawRegistrationCommand(RegistrationId.New())));
|
||||
@@ -48,7 +83,7 @@ public class WithdrawRegistrationTests
|
||||
var store = new FakeRegistrationStore();
|
||||
var registration = Registration.Submit("123456782");
|
||||
store.Seed(registration);
|
||||
var handler = new WithdrawRegistration(store);
|
||||
var handler = new WithdrawRegistration(store, NoTasks());
|
||||
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
await handler.HandleAsync(new WithdrawRegistrationCommand(registration.Id));
|
||||
|
||||
Reference in New Issue
Block a user