feat(domain): BIG Domain Service skeleton with the Registration aggregate (closes #6) #61

Merged
not merged 16 commits from feat/6-domain-service into main 2026-07-01 08:46:22 +00:00
2 changed files with 25 additions and 7 deletions
Showing only changes of commit 53751fd1bc - Show all commits

View File

@@ -7,8 +7,6 @@ namespace Big.Domain;
/// </summary> /// </summary>
public sealed class Registration public sealed class Registration
{ {
// STUB (red): mutators are no-ops and Submit leaves the bsn empty so the behaviour tests
// compile and fail on their assertions. The green commit implements the invariants.
private Registration(RegistrationId id, string bsn) private Registration(RegistrationId id, string bsn)
{ {
Id = id; Id = id;
@@ -31,17 +29,37 @@ public sealed class Registration
public Uri? ZaakUrl { get; private set; } public Uri? ZaakUrl { get; private set; }
/// <summary>Submit a new registration. It begins in <see cref="RegistrationStatus.Ingediend"/>.</summary> /// <summary>Submit a new registration. It begins in <see cref="RegistrationStatus.Ingediend"/>.</summary>
public static Registration Submit(string bsn) => new(RegistrationId.New(), string.Empty); public static Registration Submit(string bsn)
{
ArgumentException.ThrowIfNullOrWhiteSpace(bsn);
return new Registration(RegistrationId.New(), bsn);
}
/// <summary>Record that the registratie workflow process has been started for this registration.</summary> /// <summary>Record that the registratie workflow process has been started for this registration.</summary>
public void RecordProcessStarted(string processInstanceId) public void RecordProcessStarted(string processInstanceId)
{ {
// STUB (red). ArgumentException.ThrowIfNullOrWhiteSpace(processInstanceId);
ProcessInstanceId = processInstanceId;
} }
/// <summary>Attach the zaak the ACL opened. Idempotent on the same URL; a conflicting URL is rejected.</summary> /// <summary>
/// Attach the zaak the ACL opened. The external-task worker may deliver the same job more than
/// once (at-least-once), so re-attaching the identical URL is a no-op; a different URL signals a
/// genuine conflict and is rejected. The status stays <see cref="RegistrationStatus.Ingediend"/>:
/// opening the zaak does not advance the registration's lifecycle in this slice.
/// </summary>
public void AttachZaak(Uri zaakUrl) public void AttachZaak(Uri zaakUrl)
{ {
// STUB (red). ArgumentNullException.ThrowIfNull(zaakUrl);
if (ZaakUrl is not null)
{
if (ZaakUrl != zaakUrl)
throw new InvalidOperationException(
$"Registration {Id} already has zaak {ZaakUrl}; cannot attach a different zaak {zaakUrl}.");
return;
}
ZaakUrl = zaakUrl;
} }
} }

View File

@@ -21,7 +21,7 @@ public class RegistrationTests
[InlineData(" ")] [InlineData(" ")]
[InlineData(null)] [InlineData(null)]
public void Submitting_without_a_bsn_is_rejected(string? bsn) public void Submitting_without_a_bsn_is_rejected(string? bsn)
=> Assert.Throws<ArgumentException>(() => Registration.Submit(bsn!)); => Assert.ThrowsAny<ArgumentException>(() => Registration.Submit(bsn!));
[Fact] [Fact]
public void Recording_the_started_process_keeps_its_instance_id() public void Recording_the_started_process_keeps_its_instance_id()