From c005b0d627e9a0381e6e0add2faa4817f6a8e397 Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Wed, 15 Jul 2026 11:56:29 +0200 Subject: [PATCH] test(domain): the beoordeling decision completes the Flowable Beoordelen task (refs #13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Red — BeoordeelRegistratie has no user-task dependency and doesn't complete the task. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Big.Tests/BeoordeelRegistratieTests.cs | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/services/domain/Big.Tests/BeoordeelRegistratieTests.cs b/services/domain/Big.Tests/BeoordeelRegistratieTests.cs index de51af2..9ad48de 100644 --- a/services/domain/Big.Tests/BeoordeelRegistratieTests.cs +++ b/services/domain/Big.Tests/BeoordeelRegistratieTests.cs @@ -6,8 +6,8 @@ namespace Big.Tests; /// /// 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 -/// AFGEWEZEN in the domain (propagating a rejection to the zaak is a later sub-slice). Both are -/// idempotent so a repeated or redelivered decision is a no-op. +/// AFGEWEZEN. Either way the decision also completes the Flowable Beoordelen task (found by +/// registrationId) so the process advances. All idempotent — a repeated decision is a no-op. /// public class BeoordeelRegistratieTests { @@ -18,6 +18,9 @@ public class BeoordeelRegistratieTests return registration; } + private static FakeUserTaskClient TaskFor(Registration registration) => + new([new BeoordelingTask("task-1", registration.Id)]); + [Fact] 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 registration = WithZaak(); 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)); @@ -34,6 +38,8 @@ public class BeoordeelRegistratieTests Assert.Equal(FakeAclClient.DefaultZaakUrl, acl.ApprovedZaakUrl); Assert.Equal(1, acl.ApproveCallCount); 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] @@ -43,7 +49,8 @@ public class BeoordeelRegistratieTests var acl = new FakeAclClient(); var registration = WithZaak(); 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)); @@ -51,6 +58,7 @@ public class BeoordeelRegistratieTests Assert.Equal(RegistrationStatus.Afgewezen, saved!.Status); Assert.Equal(0, acl.ApproveCallCount); Assert.Equal(1, store.SaveCount); + Assert.Equal(("task-1", BeoordelingsBesluit.Afwijzen), tasks.Completed); } [Fact] @@ -61,7 +69,7 @@ public class BeoordeelRegistratieTests var registration = WithZaak(); registration.TakeIntoBehandeling(); 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)); @@ -73,7 +81,7 @@ public class BeoordeelRegistratieTests { var store = new FakeRegistrationStore(); var acl = new FakeAclClient(); - var handler = new BeoordeelRegistratie(store, acl); + var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([])); await Assert.ThrowsAsync(() => handler.HandleAsync(null!)); Assert.Equal(0, acl.ApproveCallCount); @@ -85,7 +93,7 @@ public class BeoordeelRegistratieTests { var store = new FakeRegistrationStore(); var acl = new FakeAclClient(); - var handler = new BeoordeelRegistratie(store, acl); + var handler = new BeoordeelRegistratie(store, acl, new FakeUserTaskClient([])); var ex = await Assert.ThrowsAsync(() => handler.HandleAsync(new BeoordeelRegistratieCommand(RegistrationId.New(), BeoordelingsBesluit.Goedkeuren))); @@ -100,7 +108,7 @@ public class BeoordeelRegistratieTests var acl = new FakeAclClient(); var registration = Registration.Submit("123456782"); // no zaak yet store.Seed(registration); - var handler = new BeoordeelRegistratie(store, acl); + var handler = new BeoordeelRegistratie(store, acl, TaskFor(registration)); var ex = await Assert.ThrowsAsync(() => handler.HandleAsync(new BeoordeelRegistratieCommand(registration.Id, BeoordelingsBesluit.Goedkeuren))); @@ -115,7 +123,7 @@ public class BeoordeelRegistratieTests var acl = new FakeAclClient(); var registration = WithZaak(); 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)); @@ -131,7 +139,7 @@ public class BeoordeelRegistratieTests var acl = new FakeAclClient(); var registration = WithZaak(); 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)); @@ -139,4 +147,22 @@ public class BeoordeelRegistratieTests Assert.Equal(1, store.SaveCount); 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); + } }