## S-10c · Close the ZGW zaak on document-timeout expiry (closes #106) Completes the S-10a/S-10b boundary flagged in ADR-0017: when a registration's 30-day document term lapses, the domain now cancels the **ZGW zaak** as well as marking the aggregate `Verlopen`, so OpenZaak and the register no longer diverge. ### What it does On expiry the `ExpireRegistrationWorker` calls the ACL to set the zaak to a distinct, non-terminal **`Geannuleerd`** status with a **`Vervallen`** resultaat (vs the approval `Afgehandeld` + `Geregistreerd`), resolved **by omschrijving** in the ACL — the ACL-first ordering mirrors approval so a failed ZGW call leaves the job for redelivery rather than diverging the two. **Path:** Flowable P30D timer → `RegistratieVerlopen` job → domain `ExpireRegistrationWorker` → ACL `POST /annuleringen` → ZGW `resultaten` + `statussen` (Geannuleerd) → aggregate `Verlopen`. ### Layers touched (each red→green) - **ACL gateway** — `SetZaakToCancellationStatusAsync` (Geannuleerd + Vervallen by name); approval now resolves its `Geregistreerd` resultaat by name too (a second resultaattype now exists). - **ACL service/API** — `AclService.CancelZaakAsync` + `POST /annuleringen`. - **Domain** — `IAclClient.CancelZaakAsync` + client; expiry worker cancels the zaak before advancing to `Verlopen`, guarded against redelivery double-cancel. - **Seed** — non-terminal `Geannuleerd` statustype (volgnummer 2; `Afgehandeld` → 3) + `Vervallen` resultaattype, both idempotent by omschrijving and sharing the zaaktype's procestype. - **Verify/integration** — ACL↔OpenZaak integration test (live `Geannuleerd` + resultaat); `run-domain-check.sh` fires the real P30D timer and asserts the zaak reaches `Geannuleerd` end-to-end; BDD scenario asserts cancel-on-timeout vs untouched-when-in-time. - **Docs** — ADR-0019 (cancellation modelling decision), demo-script, BACKLOG. ### Design note (ADR-0019) ZGW allows only one eindstatus per zaaktype, so `Geannuleerd` is modelled as a **non-terminal** status (it records a cancellation status + resultaat but does not set `einddatum`). This follows the issue's explicit "distinct statustype + resultaat" outcome; the shared-eindstatus alternative is recorded in the ADR. ### Tests Unit + acceptance all green locally (Acl 38, Big 134, Acceptance 17, Bff 33, EventSubscriber 19). Integration + verify-stack run in CI (need live OpenZaak + selectielijst egress). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #109
65 lines
3.0 KiB
C#
65 lines
3.0 KiB
C#
using Acceptance.Support;
|
|
using Big.Application;
|
|
using Big.Domain;
|
|
using Big.Infrastructure;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Reqnroll;
|
|
using Xunit;
|
|
|
|
namespace Acceptance.Steps;
|
|
|
|
/// <summary>Bindings for <c>EenDocumentTermijnVerlopen.feature</c> (S-10a). Drives the timeout worker
|
|
/// (<see cref="RegistratieVerlopenProcessor"/> over the <see cref="ExpireRegistrationWorker"/>) against
|
|
/// an in-memory Flowable stand-in and a shared registration store; one instance per scenario. The
|
|
/// interrupting 30-day timer either cancels the wait and expires the registration, or — if the
|
|
/// documents arrived first — never fires; the scenario asserts on the aggregate's status.</summary>
|
|
[Binding]
|
|
[Scope(Feature = "Een documenttermijn laten verlopen")]
|
|
public sealed class EenDocumentTermijnVerlopenSteps
|
|
{
|
|
private static readonly Uri ZaakUrl = new("http://openzaak/zaken/api/v1/zaken/acc-timeout");
|
|
|
|
private readonly InMemoryDocumentTimeoutClient _flowable = new();
|
|
private readonly Support.InMemoryRegistrationStore _store = new();
|
|
private readonly InMemoryAclClient _acl = new();
|
|
private Registration _registration = null!;
|
|
private string _processInstanceId = "";
|
|
|
|
[Given("a registration parked at the WachtOpDocumenten task")]
|
|
public async Task GivenARegistrationParkedAtWachtOpDocumenten()
|
|
{
|
|
_registration = Registration.Submit("123456782");
|
|
// By the time it parks at WachtOpDocumenten its zaak has been opened (OpenZaakAanmaken runs
|
|
// earlier), so a timeout has a zaak to cancel.
|
|
_registration.AttachZaak(ZaakUrl);
|
|
await _store.SaveAsync(_registration);
|
|
_processInstanceId = _flowable.ParkWaitingForDocuments(_registration.Id);
|
|
}
|
|
|
|
[When("the 30-day document timer fires")]
|
|
public void WhenTheDocumentTimerFires() => _flowable.FireDocumentTimer(_processInstanceId);
|
|
|
|
[When("the documents arrive before the timer fires")]
|
|
public void WhenTheDocumentsArriveBeforeTheTimer() => _flowable.ReceiveDocuments(_processInstanceId);
|
|
|
|
[When("the document-timeout worker runs")]
|
|
public async Task WhenTheTimeoutWorkerRuns()
|
|
=> await new RegistratieVerlopenProcessor(
|
|
_flowable, new ExpireRegistrationWorker(_store, _acl),
|
|
NullLogger<RegistratieVerlopenProcessor>.Instance).PumpOnceAsync(5);
|
|
|
|
[Then("the registration is verlopen")]
|
|
public async Task ThenTheRegistrationIsVerlopen()
|
|
=> Assert.Equal(RegistrationStatus.Verlopen, (await _store.GetAsync(_registration.Id))!.Status);
|
|
|
|
[Then("the registration is not verlopen")]
|
|
public async Task ThenTheRegistrationIsNotVerlopen()
|
|
=> Assert.Equal(RegistrationStatus.Ingediend, (await _store.GetAsync(_registration.Id))!.Status);
|
|
|
|
[Then("the zaak is cancelled in ZGW")]
|
|
public void ThenTheZaakIsCancelled() => Assert.Equal(ZaakUrl, _acl.CancelledZaakUrl);
|
|
|
|
[Then("the zaak is not cancelled in ZGW")]
|
|
public void ThenTheZaakIsNotCancelled() => Assert.Null(_acl.CancelledZaakUrl);
|
|
}
|