From f39ec2afa3f49214dbe7735c60514f4fb641738f Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Mon, 20 Jul 2026 09:41:29 +0200 Subject: [PATCH] test(domain): a document-wait timeout expires the registration to Verlopen (refs #102) RED: Registration.Expire() moves an open registration to a new terminal Verlopen status, needs no zaak, is idempotent on redelivery, and is rejected once the registration has been decided or withdrawn. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../domain/Big.Tests/RegistrationTests.cs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/services/domain/Big.Tests/RegistrationTests.cs b/services/domain/Big.Tests/RegistrationTests.cs index b166831..003021e 100644 --- a/services/domain/Big.Tests/RegistrationTests.cs +++ b/services/domain/Big.Tests/RegistrationTests.cs @@ -294,4 +294,63 @@ public class RegistrationTests Assert.Contains("only an INGEDIEND", ex.Message); Assert.Equal(RegistrationStatus.Afgewezen, registration.Status); } + + [Fact] + public void Expiring_an_ingediend_registration_sets_it_verlopen() + { + // The 30-day document-wait timer fired before the documents arrived (S-10a): the case is + // cancelled and the aggregate becomes terminal VERLOPEN. + var registration = Registration.Submit("123456782"); + + registration.Expire(); + + Assert.Equal(RegistrationStatus.Verlopen, registration.Status); + } + + [Fact] + public void Expiring_needs_no_zaak() + { + // The timer fires on a purely time-based boundary; expiry does not depend on the zaak. + var registration = Registration.Submit("123456782"); + + registration.Expire(); + + Assert.Equal(RegistrationStatus.Verlopen, registration.Status); + Assert.Null(registration.ZaakUrl); + } + + [Fact] + public void Re_expiring_an_already_verlopen_registration_is_idempotent() + { + // The RegistratieVerlopen worker job may be redelivered (ยง8.6); re-expiring is a no-op. + var registration = Registration.Submit("123456782"); + registration.Expire(); + + registration.Expire(); + + Assert.Equal(RegistrationStatus.Verlopen, registration.Status); + } + + [Fact] + public void Expiring_an_approved_registration_is_rejected() + { + var registration = Registration.Submit("123456782"); + registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc")); + registration.Approve(); + + var ex = Assert.Throws(() => registration.Expire()); + Assert.Contains("only an INGEDIEND", ex.Message); + Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status); + } + + [Fact] + public void Expiring_a_withdrawn_registration_is_rejected() + { + var registration = Registration.Submit("123456782"); + registration.Withdraw(); + + var ex = Assert.Throws(() => registration.Expire()); + Assert.Contains("only an INGEDIEND", ex.Message); + Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status); + } }