All checks were successful
## What & why
Second half of **S-12c** (behandel-portal backend), completing the decision path per **ADR-0013**:
- **Domain:** `BeoordeelRegistratie` now, after applying the decision (aggregate + ACL for approval), **completes the open Flowable `Beoordelen` task** for that registration (found by registrationId) with the besluit, so the workflow advances. No open task → the decision still stands (completes nothing); idempotent.
- **BFF:** `POST /behandel/registrations/{id}/decide` behind the medewerker/`behandelaar` policy, forwarding `goedkeuren`/`afwijzen` to the domain. Validates the besluit vocabulary (400 on unknown) without troubling the domain.
Behavior: decide is **401** without a token, **403** without the role, **400** for an unknown besluit, **204** (forwarded) for a behandelaar.
This completes the behandel backend. **S-12d** (the Angular behandel-portal + Playwright e2e) closes umbrella #13 and retires the temporary `/approve`.
## Definition of Done
- [x] Linked issue: #13 (umbrella, `refs`)
- [x] Tests first; red → green per layer
- [x] Unit + acceptance green (`make unit`): domain 79, bff 27, acceptance 9 (acl/event-subscriber unaffected)
- [x] Beoordeling acceptance scenario asserts task completion (goedkeuren + afwijzen)
- [x] openapi.json + api-client regenerated (drift guard passes)
- [x] Mutation ≥ break(90): **domain 100%, bff 100%**
- [ ] CI green (pending)
Part of #13.
Reviewed-on: #86
83 lines
3.3 KiB
C#
83 lines
3.3 KiB
C#
using Big.Application;
|
|
using Big.Domain;
|
|
|
|
namespace Acceptance.Support;
|
|
|
|
/// <summary>An in-memory Workflow Client for the domain acceptance scenario: it records which
|
|
/// registration a process was started for and returns a fixed instance id. The acceptance test
|
|
/// drives the use case without a running Flowable (live verification is the verify-domain check).</summary>
|
|
public sealed class InMemoryWorkflowClient : IWorkflowClient
|
|
{
|
|
public const string StartedProcessInstanceId = "proc-acc-1";
|
|
|
|
public RegistrationId? StartedFor { get; private set; }
|
|
|
|
public Task<string> StartRegistrationProcessAsync(RegistrationId registrationId, CancellationToken ct = default)
|
|
{
|
|
StartedFor = registrationId;
|
|
return Task.FromResult(StartedProcessInstanceId);
|
|
}
|
|
}
|
|
|
|
/// <summary>An in-memory ACL stand-in: records the bsn it opened a zaak for and returns a fixed URL,
|
|
/// so the scenario verifies the domain crosses the ACL boundary (§8.1) without a running OpenZaak.</summary>
|
|
public sealed class InMemoryAclClient : IAclClient
|
|
{
|
|
public static readonly Uri OpenedZaakUrl = new("http://openzaak/zaken/api/v1/zaken/acc-zaak");
|
|
|
|
public string? OpenedForBsn { get; private set; }
|
|
public string? OpenedWithReference { get; private set; }
|
|
public Uri? ApprovedZaakUrl { get; private set; }
|
|
|
|
public Task<Uri> OpenZaakAsync(string bsn, string reference, CancellationToken ct = default)
|
|
{
|
|
OpenedForBsn = bsn;
|
|
OpenedWithReference = reference;
|
|
return Task.FromResult(OpenedZaakUrl);
|
|
}
|
|
|
|
public Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default)
|
|
{
|
|
ApprovedZaakUrl = zaakUrl;
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
|
|
/// <summary>An in-memory user-task client for the beoordeling acceptance scenario: it holds one open
|
|
/// Beoordelen task per registration and records the besluit each is completed with.</summary>
|
|
public sealed class InMemoryUserTaskClient : IUserTaskClient
|
|
{
|
|
private readonly List<BeoordelingTask> _open = [];
|
|
|
|
public (string TaskId, BeoordelingsBesluit Besluit)? Completed { get; private set; }
|
|
|
|
public void Open(RegistrationId registrationId) => _open.Add(new BeoordelingTask($"task-{registrationId}", registrationId));
|
|
|
|
public Task<IReadOnlyList<BeoordelingTask>> GetOpenBeoordelingenAsync(CancellationToken ct = default)
|
|
=> Task.FromResult<IReadOnlyList<BeoordelingTask>>(_open);
|
|
|
|
public Task ClaimAsync(string taskId, string behandelaar, CancellationToken ct = default) => Task.CompletedTask;
|
|
|
|
public Task CompleteBeoordelingAsync(string taskId, BeoordelingsBesluit besluit, CancellationToken ct = default)
|
|
{
|
|
Completed = (taskId, besluit);
|
|
_open.RemoveAll(t => t.TaskId == taskId);
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
|
|
/// <summary>An in-memory registration store for the domain acceptance scenario.</summary>
|
|
public sealed class InMemoryRegistrationStore : IRegistrationStore
|
|
{
|
|
private readonly Dictionary<RegistrationId, Registration> _byId = [];
|
|
|
|
public Task SaveAsync(Registration registration, CancellationToken ct = default)
|
|
{
|
|
_byId[registration.Id] = registration;
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task<Registration?> GetAsync(RegistrationId id, CancellationToken ct = default)
|
|
=> Task.FromResult(_byId.GetValueOrDefault(id));
|
|
}
|