All checks were successful
## What & why Second sub-slice of **S-12 (#13)** — the **Workflow Client gains behandelaar user-task operations**, and the process model gains the beoordeling step. - **BPMN:** `registratie.bpmn` now parks at a `Beoordelen` **userTask** (candidate group `behandelaar`) after `OpenZaakAanmaken`; `registrationId` rides along as a process variable so the werkbak can correlate each task to its aggregate. - **Workflow Client** (`IUserTaskClient`, the only code that talks to Flowable §8.2): - `GetOpenBeoordelingenAsync()` — the werkbak (open `Beoordelen` tasks + their `registrationId`) - `ClaimAsync(taskId, behandelaar)` - `CompleteBeoordelingAsync(taskId, besluit)` — carries the decision into the process as the `besluit` variable - **Live integration:** `verify-domain` now drives the full user-task lifecycle against a real Flowable — after the worker opens the zaak, it polls for the task, claims it as `merel-behandelaar`, completes it (`goedkeuren`), and asserts the process finishes. This proves the exact REST contract (`service/runtime/tasks/query` + `…/{id}` claim/complete) the client depends on. The walking skeleton is unaffected: the temporary `/approve` path still sets the zaak status directly; wiring the domain decision to *complete this task* (and driving the werkbak from the BFF) lands in **S-12c**. ## Definition of Done - [x] Linked issue: #13 (umbrella; `refs`, does not close) - [x] Tests first; red → green - [x] Unit + acceptance green (`make unit`): domain 76, acceptance 9 (acl/event-subscriber/bff unaffected) - [x] Mutation ≥ break(90): **domain 100%** (killed the new survivors *and* the pre-existing `FlowableWorkflowClient` baseline) - [x] Live Flowable user-task lifecycle asserted in `verify-domain` - [ ] CI green (pending) Part of #13. Reviewed-on: #83
98 lines
4.8 KiB
C#
98 lines
4.8 KiB
C#
using Big.Application;
|
|
using Big.Domain;
|
|
using Big.Infrastructure;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Options bound from configuration (compose sets Flowable__* and Acl__* env vars).
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Flowable").Get<FlowableOptions>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Flowable'"));
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Acl").Get<AclOptions>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Acl'"));
|
|
|
|
// The in-memory registration store is shared between the submit endpoint and the worker (ADR-0009).
|
|
builder.Services.AddSingleton<IRegistrationStore, InMemoryRegistrationStore>();
|
|
|
|
// The Workflow Client is one type behind two ports (start side + worker side); both resolve to the
|
|
// same HttpClient-backed implementation — the only code that talks to Flowable (§8.2).
|
|
builder.Services.AddHttpClient<FlowableWorkflowClient>();
|
|
builder.Services.AddTransient<IWorkflowClient>(sp => sp.GetRequiredService<FlowableWorkflowClient>());
|
|
builder.Services.AddTransient<IExternalWorkerClient>(sp => sp.GetRequiredService<FlowableWorkflowClient>());
|
|
builder.Services.AddTransient<IUserTaskClient>(sp => sp.GetRequiredService<FlowableWorkflowClient>());
|
|
builder.Services.AddHttpClient<IAclClient, AclHttpClient>();
|
|
|
|
builder.Services.AddScoped<SubmitRegistration>();
|
|
builder.Services.AddScoped<ApproveRegistration>();
|
|
builder.Services.AddScoped<BeoordeelRegistratie>();
|
|
builder.Services.AddScoped<OpenZaakWorker>();
|
|
builder.Services.AddScoped<OpenZaakJobProcessor>();
|
|
|
|
// The hosted external-task job worker polls Flowable and drives OpenZaakAanmaken to completion.
|
|
builder.Services.AddHostedService<OpenZaakJobPump>();
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapGet("/health", () => "Healthy");
|
|
|
|
// Submit a registration. The aggregate is created (INGEDIEND) and the registratie process started;
|
|
// the zaak is opened later, off the request path, by the worker — so this returns 202 Accepted with
|
|
// a location to read the registration's progress (ADR-0009, eventual consistency).
|
|
app.MapPost("/registrations", async (SubmitRegistrationRequest body, SubmitRegistration submit, CancellationToken ct) =>
|
|
{
|
|
var id = await submit.HandleAsync(new SubmitRegistrationCommand(body.Bsn), ct);
|
|
return Results.Accepted($"/registrations/{id}", new RegistrationResponse(id.ToString(), RegistrationStatus.Ingediend.ToString(), null));
|
|
});
|
|
|
|
// Temporary admin endpoint (S-09b): approve a registration — the behandelaar's decision, until the
|
|
// behandel-portal exists (S-12). The zaak's final status is set via the ACL, which flows back over
|
|
// NRC to the projection, making the entry publicly visible as INGESCHREVEN. Idempotent.
|
|
app.MapPost("/registrations/{id}/approve", async (string id, ApproveRegistration approve, CancellationToken ct) =>
|
|
{
|
|
if (!Guid.TryParse(id, out var guid))
|
|
return Results.NotFound();
|
|
|
|
await approve.HandleAsync(new ApproveRegistrationCommand(new RegistrationId(guid)), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// The behandelaar's beoordeling (S-12): decide a registration goedkeuren (→ INGESCHREVEN, sets the
|
|
// zaak's final status via the ACL) or afwijzen (→ AFGEWEZEN). Idempotent. This is the domain contract
|
|
// the behandel-portal's decision reaches through the BFF; it supersedes the temporary /approve above,
|
|
// which is retired once the portal lands.
|
|
app.MapPost("/registrations/{id}/decide", async (string id, DecideRequest body, BeoordeelRegistratie beoordeel, CancellationToken ct) =>
|
|
{
|
|
if (!Guid.TryParse(id, out var guid))
|
|
return Results.NotFound();
|
|
|
|
if (!Enum.TryParse<BeoordelingsBesluit>(body.Besluit, ignoreCase: true, out var besluit))
|
|
return Results.BadRequest(new { error = $"Unknown besluit '{body.Besluit}'. Expected 'goedkeuren' or 'afwijzen'." });
|
|
|
|
await beoordeel.HandleAsync(new BeoordeelRegistratieCommand(new RegistrationId(guid), besluit), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// Read a registration. Its zaak URL appears once the worker has opened the zaak (eventually).
|
|
app.MapGet("/registrations/{id}", async (string id, IRegistrationStore store, CancellationToken ct) =>
|
|
{
|
|
if (!Guid.TryParse(id, out var guid))
|
|
return Results.NotFound();
|
|
|
|
var registration = await store.GetAsync(new RegistrationId(guid), ct);
|
|
return registration is null
|
|
? Results.NotFound()
|
|
: Results.Ok(new RegistrationResponse(
|
|
registration.Id.ToString(), registration.Status.ToString(), registration.ZaakUrl?.ToString()));
|
|
});
|
|
|
|
await app.RunAsync();
|
|
|
|
public sealed record SubmitRegistrationRequest(string Bsn);
|
|
|
|
public sealed record DecideRequest(string Besluit);
|
|
|
|
public sealed record RegistrationResponse(string RegistrationId, string Status, string? ZaakUrl);
|
|
|
|
public partial class Program;
|