## What & why S-13: a diploma's origin decides its route. A **DMN** (`diploma-eligibility`) is evaluated inline by the registratie process as a **`businessRuleTask`**; an exclusive gateway routes a **foreign** (Buitenlands) diploma through a new **CBGVAdvies** user task before `Beoordelen`, a **domestic** one straight there (PRD flow 4). The domain's only new job is carrying the diploma origin and passing it as a process start variable. Chose **Option B (DMN in the BPMN)** over the issue's literal "evaluated by the Domain Service via Workflow Client" wording — keeps the decision a first-class workflow artefact and §8.2 clean. Rationale in **ADR-0016** (proposal #100); noted on this issue. Closes #14 ## Definition of Done - [x] Linked Gitea issue (above). - [x] Failing test committed before the implementation. - [x] Implementation makes the test pass. - [x] Conventional Commits referencing the issue (`refs #14`). - [ ] CI green — all Gitea Actions jobs. - [x] `docker compose up` from a fresh clone reaches green health checks within 3 minutes (additive; DMN deployed by flowable-init). - [x] Docs updated (ADR-0016, demo note). - [x] ADR added (`docs/architecture/adr-0016-diploma-eligibility-dmn.md`). - [x] Demo note in `docs/demo-script.md`. ## How it was built (TDD) - **Domain**: `DiplomaOrigin` on the aggregate + submit command; threaded through the process-start port so the Workflow Client emits a `diplomaOrigin` start variable. Red → green. - **DMN + BPMN**: `workflows/diploma-eligibility.dmn` (origin → route); `businessRuleTask` + exclusive gateway + `CBGVAdvies` user task in `registratie.bpmn`; DMN deployed to Flowable's DMN engine by `flowable-init`. - **Both paths**: `Een diploma op herkomst routeren` acceptance scenarios (origin carried into the process) + unit tests; verify-domain drives a foreign registration through CBGVAdvies→Beoordelen and the domestic one straight to Beoordelen — exercising both DMN branches live. ## Notes for reviewers - Deviation from the issue's Option-A wording is deliberate and recorded (ADR-0016); the outcome is unchanged. - The self-service eIDAS→foreign wiring is out of scope here (this slice is area:domain + area:workflow); the domain submit accepts an optional `diplomaOrigin` so the foreign path is drivable. - Local green: domain unit 109, acceptance 15, `dotnet format`, Release build (0 errors), **domain mutation 95.39%** (break 90). The DMN/`businessRuleTask` REST wiring is CI-verified on verify-stack (no local full-stack run here). Reviewed-on: #101
80 lines
3.0 KiB
C#
80 lines
3.0 KiB
C#
using Big.Application;
|
|
using Big.Domain;
|
|
|
|
namespace Big.Tests;
|
|
|
|
public class SubmitRegistrationTests
|
|
{
|
|
[Fact]
|
|
public async Task Submitting_persists_an_ingediend_registration_and_starts_the_process()
|
|
{
|
|
var store = new FakeRegistrationStore();
|
|
var workflow = new FakeWorkflowClient(processInstanceId: "proc-42");
|
|
var handler = new SubmitRegistration(store, workflow);
|
|
|
|
var id = await handler.HandleAsync(new SubmitRegistrationCommand("123456782"));
|
|
|
|
var saved = await store.GetAsync(id);
|
|
Assert.NotNull(saved);
|
|
Assert.Equal("123456782", saved.Bsn);
|
|
Assert.Equal(RegistrationStatus.Ingediend, saved.Status);
|
|
Assert.Equal("proc-42", saved.ProcessInstanceId);
|
|
Assert.Equal(id, workflow.StartedFor);
|
|
Assert.Null(saved.ZaakUrl);
|
|
// Persisted twice: once before starting the process, once after recording the instance id.
|
|
Assert.Equal(2, store.SaveCount);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Submitting_a_foreign_diploma_carries_its_origin_to_the_process()
|
|
{
|
|
var store = new FakeRegistrationStore();
|
|
var workflow = new FakeWorkflowClient();
|
|
var handler = new SubmitRegistration(store, workflow);
|
|
|
|
var id = await handler.HandleAsync(new SubmitRegistrationCommand("123456782", DiplomaOrigin.Buitenlands));
|
|
|
|
Assert.Equal(DiplomaOrigin.Buitenlands, (await store.GetAsync(id))!.DiplomaOrigin);
|
|
Assert.Equal(DiplomaOrigin.Buitenlands, workflow.StartedWithOrigin);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Rejects_a_null_command_without_touching_the_store_or_workflow()
|
|
{
|
|
var store = new FakeRegistrationStore();
|
|
var workflow = new FakeWorkflowClient();
|
|
var handler = new SubmitRegistration(store, workflow);
|
|
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => handler.HandleAsync(null!));
|
|
Assert.Equal(0, store.SaveCount);
|
|
Assert.Null(workflow.StartedFor);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Submitting_persists_the_registration_before_starting_the_process()
|
|
{
|
|
// The worker correlates the OpenZaakAanmaken job back to the aggregate by id, so the
|
|
// aggregate must already be persisted when the process starts (ADR-0009).
|
|
var store = new FakeRegistrationStore();
|
|
Registration? visibleAtStart = null;
|
|
var workflow = new FakeWorkflowClient(onStart: id => visibleAtStart = store.GetAsync(id).Result);
|
|
var handler = new SubmitRegistration(store, workflow);
|
|
|
|
await handler.HandleAsync(new SubmitRegistrationCommand("123456782"));
|
|
|
|
Assert.NotNull(visibleAtStart);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Submitting_without_a_bsn_is_rejected_and_starts_no_process()
|
|
{
|
|
var store = new FakeRegistrationStore();
|
|
var workflow = new FakeWorkflowClient();
|
|
var handler = new SubmitRegistration(store, workflow);
|
|
|
|
await Assert.ThrowsAnyAsync<ArgumentException>(
|
|
() => handler.HandleAsync(new SubmitRegistrationCommand("")));
|
|
Assert.Null(workflow.StartedFor);
|
|
}
|
|
}
|