test(domain): the beoordeling decision completes the Flowable Beoordelen task (refs #13)

Red — BeoordeelRegistratie has no user-task dependency and doesn't complete the task.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-15 11:56:29 +02:00
parent 9c3da48d8e
commit c005b0d627

View File

@@ -6,8 +6,8 @@ namespace Big.Tests;
/// <summary> /// <summary>
/// The beoordeling use case (S-12): a behandelaar's decision on a registration. Goedkeuren sets the /// The beoordeling use case (S-12): a behandelaar's decision on a registration. Goedkeuren sets the
/// zaak's final status via the ACL (§8.1) and marks the aggregate INGESCHREVEN; Afwijzen marks it /// zaak's final status via the ACL (§8.1) and marks the aggregate INGESCHREVEN; Afwijzen marks it
/// AFGEWEZEN in the domain (propagating a rejection to the zaak is a later sub-slice). Both are /// AFGEWEZEN. Either way the decision also completes the Flowable Beoordelen task (found by
/// idempotent so a repeated or redelivered decision is a no-op. /// registrationId) so the process advances. All idempotent a repeated decision is a no-op.
/// </summary> /// </summary>
public class BeoordeelRegistratieTests public class BeoordeelRegistratieTests
{ {
@@ -18,6 +18,9 @@ public class BeoordeelRegistratieTests
return registration; return registration;
} }
private static FakeUserTaskClient TaskFor(Registration registration) =>
new([new BeoordelingTask("task-1", registration.Id)]);
[Fact] [Fact]
public async Task Goedkeuren_sets_the_zaak_status_via_the_acl_and_marks_the_registration_ingeschreven() public async Task Goedkeuren_sets_the_zaak_status_via_the_acl_and_marks_the_registration_ingeschreven()
{ {
@@ -25,7 +28,8 @@ public class BeoordeelRegistratieTests
var acl = new FakeAclClient(); var acl = new FakeAclClient();
var registration = WithZaak(); var registration = WithZaak();
store.Seed(registration); store.Seed(registration);
var handler = new BeoordeelRegistratie(store, acl); var tasks = TaskFor(registration);
var handler = new BeoordeelRegistratie(store, acl, tasks);
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren)); await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
@@ -34,6 +38,8 @@ public class BeoordeelRegistratieTests
Assert.Equal(FakeAclClient.DefaultZaakUrl, acl.ApprovedZaakUrl); Assert.Equal(FakeAclClient.DefaultZaakUrl, acl.ApprovedZaakUrl);
Assert.Equal(1, acl.ApproveCallCount); Assert.Equal(1, acl.ApproveCallCount);
Assert.Equal(1, store.SaveCount); Assert.Equal(1, store.SaveCount);
// The behandelaar's decision advances the workflow: the Beoordelen task is completed.
Assert.Equal(("task-1", BeoordelingsBesluit.Goedkeuren), tasks.Completed);
} }
[Fact] [Fact]
@@ -43,7 +49,8 @@ public class BeoordeelRegistratieTests
var acl = new FakeAclClient(); var acl = new FakeAclClient();
var registration = WithZaak(); var registration = WithZaak();
store.Seed(registration); store.Seed(registration);
var handler = new BeoordeelRegistratie(store, acl); var tasks = TaskFor(registration);
var handler = new BeoordeelRegistratie(store, acl, tasks);
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen)); await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
@@ -51,6 +58,7 @@ public class BeoordeelRegistratieTests
Assert.Equal(RegistrationStatus.Afgewezen, saved!.Status); Assert.Equal(RegistrationStatus.Afgewezen, saved!.Status);
Assert.Equal(0, acl.ApproveCallCount); Assert.Equal(0, acl.ApproveCallCount);
Assert.Equal(1, store.SaveCount); Assert.Equal(1, store.SaveCount);
Assert.Equal(("task-1", BeoordelingsBesluit.Afwijzen), tasks.Completed);
} }
[Fact] [Fact]
@@ -61,7 +69,7 @@ public class BeoordeelRegistratieTests
var registration = WithZaak(); var registration = WithZaak();
registration.TakeIntoBehandeling(); registration.TakeIntoBehandeling();
store.Seed(registration); store.Seed(registration);
var handler = new BeoordeelRegistratie(store, acl); var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren)); await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
@@ -73,7 +81,7 @@ public class BeoordeelRegistratieTests
{ {
var store = new FakeRegistrationStore(); var store = new FakeRegistrationStore();
var acl = new FakeAclClient(); var acl = new FakeAclClient();
var handler = new BeoordeelRegistratie(store, acl); var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([]));
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!)); await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
Assert.Equal(0, acl.ApproveCallCount); Assert.Equal(0, acl.ApproveCallCount);
@@ -85,7 +93,7 @@ public class BeoordeelRegistratieTests
{ {
var store = new FakeRegistrationStore(); var store = new FakeRegistrationStore();
var acl = new FakeAclClient(); var acl = new FakeAclClient();
var handler = new BeoordeelRegistratie(store, acl); var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([]));
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => var ex = await Assert.ThrowsAsync<InvalidOperationException>(() =>
handler.HandleAsync(new BeoordeelRegistratieCommand(RegistrationId.New(), BeoordelingsBesluit.Goedkeuren))); handler.HandleAsync(new BeoordeelRegistratieCommand(RegistrationId.New(), BeoordelingsBesluit.Goedkeuren)));
@@ -100,7 +108,7 @@ public class BeoordeelRegistratieTests
var acl = new FakeAclClient(); var acl = new FakeAclClient();
var registration = Registration.Submit("123456782"); // no zaak yet var registration = Registration.Submit("123456782"); // no zaak yet
store.Seed(registration); store.Seed(registration);
var handler = new BeoordeelRegistratie(store, acl); var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => var ex = await Assert.ThrowsAsync<InvalidOperationException>(() =>
handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren))); handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren)));
@@ -115,7 +123,7 @@ public class BeoordeelRegistratieTests
var acl = new FakeAclClient(); var acl = new FakeAclClient();
var registration = WithZaak(); var registration = WithZaak();
store.Seed(registration); store.Seed(registration);
var handler = new BeoordeelRegistratie(store, acl); var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren)); await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren)); await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
@@ -131,7 +139,7 @@ public class BeoordeelRegistratieTests
var acl = new FakeAclClient(); var acl = new FakeAclClient();
var registration = WithZaak(); var registration = WithZaak();
store.Seed(registration); store.Seed(registration);
var handler = new BeoordeelRegistratie(store, acl); var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration));
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen)); await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen)); await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Afwijzen));
@@ -139,4 +147,22 @@ public class BeoordeelRegistratieTests
Assert.Equal(1, store.SaveCount); Assert.Equal(1, store.SaveCount);
Assert.Equal(RegistrationStatus.Afgewezen, (await store.GetAsync(registration.Id))!.Status); Assert.Equal(RegistrationStatus.Afgewezen, (await store.GetAsync(registration.Id))!.Status);
} }
[Fact]
public async Task Deciding_completes_no_task_when_none_is_open_for_the_registration()
{
// The task may already be gone (redelivery / manual completion). The decision still applies
// and simply completes nothing rather than failing.
var store = new FakeRegistrationStore();
var acl = new FakeAclClient();
var registration = WithZaak();
store.Seed(registration);
var tasks = new FakeUserTaskClient([]); // no open task for this registration
var handler = new BeoordeelRegistratie(store, acl, tasks);
await handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren));
Assert.Equal(RegistrationStatus.Ingeschreven, (await store.GetAsync(registration.Id))!.Status);
Assert.Null(tasks.Completed);
}
} }