## 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
298 lines
9.7 KiB
C#
298 lines
9.7 KiB
C#
using Big.Domain;
|
|
|
|
namespace Big.Tests;
|
|
|
|
public class RegistrationTests
|
|
{
|
|
[Fact]
|
|
public void Submitting_a_registration_starts_in_ingediend()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
Assert.Equal(RegistrationStatus.Ingediend, registration.Status);
|
|
Assert.Equal("123456782", registration.Bsn);
|
|
Assert.NotEqual(Guid.Empty, registration.Id.Value);
|
|
Assert.Null(registration.ZaakUrl);
|
|
Assert.Null(registration.ProcessInstanceId);
|
|
}
|
|
|
|
[Fact]
|
|
public void A_registration_defaults_to_a_domestic_diploma()
|
|
=> Assert.Equal(DiplomaOrigin.Binnenlands, Registration.Submit("123456782").DiplomaOrigin);
|
|
|
|
[Fact]
|
|
public void A_foreign_diploma_submission_records_its_origin()
|
|
=> Assert.Equal(DiplomaOrigin.Buitenlands,
|
|
Registration.Submit("123456782", DiplomaOrigin.Buitenlands).DiplomaOrigin);
|
|
|
|
[Theory]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
[InlineData(null)]
|
|
public void Submitting_without_a_bsn_is_rejected(string? bsn)
|
|
=> Assert.ThrowsAny<ArgumentException>(() => Registration.Submit(bsn!));
|
|
|
|
[Fact]
|
|
public void Recording_the_started_process_keeps_its_instance_id()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
registration.RecordProcessStarted("proc-42");
|
|
|
|
Assert.Equal("proc-42", registration.ProcessInstanceId);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
[InlineData(null)]
|
|
public void Recording_an_empty_process_instance_id_is_rejected(string? processInstanceId)
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
Assert.ThrowsAny<ArgumentException>(() => registration.RecordProcessStarted(processInstanceId!));
|
|
}
|
|
|
|
[Fact]
|
|
public void Attaching_a_zaak_records_its_url_and_keeps_the_status_ingediend()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
var zaak = new Uri("http://openzaak/zaken/api/v1/zaken/abc");
|
|
|
|
registration.AttachZaak(zaak);
|
|
|
|
Assert.Equal(zaak, registration.ZaakUrl);
|
|
Assert.Equal(RegistrationStatus.Ingediend, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Attaching_a_null_zaak_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
Assert.Throws<ArgumentNullException>(() => registration.AttachZaak(null!));
|
|
}
|
|
|
|
[Fact]
|
|
public void Re_attaching_the_same_zaak_is_idempotent()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
var zaak = new Uri("http://openzaak/zaken/api/v1/zaken/abc");
|
|
|
|
registration.AttachZaak(zaak);
|
|
registration.AttachZaak(zaak);
|
|
|
|
Assert.Equal(zaak, registration.ZaakUrl);
|
|
}
|
|
|
|
[Fact]
|
|
public void Attaching_a_conflicting_zaak_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
|
|
|
var ex = Assert.Throws<InvalidOperationException>(
|
|
() => registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/other")));
|
|
Assert.Contains("/zaken/abc", ex.Message);
|
|
Assert.Contains("/zaken/other", ex.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void Approving_a_registration_with_a_zaak_sets_it_ingeschreven()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
|
|
|
registration.Approve();
|
|
|
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Approving_before_the_zaak_is_opened_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.Approve());
|
|
|
|
Assert.Contains("no zaak", ex.Message, StringComparison.OrdinalIgnoreCase);
|
|
Assert.Equal(RegistrationStatus.Ingediend, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Approving_an_already_ingeschreven_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<InvalidOperationException>(() => registration.Approve());
|
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Taking_a_registration_into_behandeling_moves_it_to_in_behandeling()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
registration.TakeIntoBehandeling();
|
|
|
|
Assert.Equal(RegistrationStatus.InBehandeling, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Re_taking_an_in_behandeling_registration_is_idempotent()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.TakeIntoBehandeling();
|
|
|
|
registration.TakeIntoBehandeling();
|
|
|
|
Assert.Equal(RegistrationStatus.InBehandeling, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Taking_a_decided_registration_into_behandeling_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
|
registration.Approve();
|
|
|
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.TakeIntoBehandeling());
|
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Approving_an_in_behandeling_registration_with_a_zaak_sets_it_ingeschreven()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
|
registration.TakeIntoBehandeling();
|
|
|
|
registration.Approve();
|
|
|
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Rejecting_a_registration_sets_it_afgewezen()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
registration.Reject();
|
|
|
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Rejecting_needs_no_zaak()
|
|
{
|
|
// A registration can be turned down before its zaak is ever opened, so Reject must not require one.
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
registration.Reject();
|
|
|
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
|
Assert.Null(registration.ZaakUrl);
|
|
}
|
|
|
|
[Fact]
|
|
public void Rejecting_an_in_behandeling_registration_sets_it_afgewezen()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.TakeIntoBehandeling();
|
|
|
|
registration.Reject();
|
|
|
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Deciding_an_already_decided_registration_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.Reject();
|
|
|
|
var approveEx = Assert.Throws<InvalidOperationException>(() =>
|
|
{
|
|
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
|
registration.Approve();
|
|
});
|
|
Assert.Contains("IN_BEHANDELING", approveEx.Message);
|
|
|
|
var rejectEx = Assert.Throws<InvalidOperationException>(() => registration.Reject());
|
|
Assert.Contains("Afgewezen", rejectEx.Message);
|
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Withdrawing_an_ingediend_registration_sets_it_ingetrokken()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
registration.Withdraw();
|
|
|
|
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Withdrawing_an_in_behandeling_registration_sets_it_ingetrokken()
|
|
{
|
|
// A citizen can still pull a registration back while a behandelaar has it in behandeling.
|
|
var registration = Registration.Submit("123456782");
|
|
registration.TakeIntoBehandeling();
|
|
|
|
registration.Withdraw();
|
|
|
|
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Withdrawing_needs_no_zaak()
|
|
{
|
|
// Withdrawal is the citizen's own action and does not depend on the zaak having been opened.
|
|
var registration = Registration.Submit("123456782");
|
|
|
|
registration.Withdraw();
|
|
|
|
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
|
Assert.Null(registration.ZaakUrl);
|
|
}
|
|
|
|
[Fact]
|
|
public void Re_withdrawing_an_already_ingetrokken_registration_is_idempotent()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.Withdraw();
|
|
|
|
registration.Withdraw();
|
|
|
|
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Withdrawing_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<InvalidOperationException>(() => registration.Withdraw());
|
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
|
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Withdrawing_a_rejected_registration_is_rejected()
|
|
{
|
|
var registration = Registration.Submit("123456782");
|
|
registration.Reject();
|
|
|
|
var ex = Assert.Throws<InvalidOperationException>(() => registration.Withdraw());
|
|
Assert.Contains("only an INGEDIEND", ex.Message);
|
|
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
|
}
|
|
}
|