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
4 changed files with 123 additions and 0 deletions
Showing only changes of commit 79dcd8f14b - Show all commits

View File

@@ -19,6 +19,7 @@
<ProjectReference Include="..\..\services\acl\Acl.Application\Acl.Application.csproj" /> <ProjectReference Include="..\..\services\acl\Acl.Application\Acl.Application.csproj" />
<ProjectReference Include="..\..\services\acl\Acl.Infrastructure\Acl.Infrastructure.csproj" /> <ProjectReference Include="..\..\services\acl\Acl.Infrastructure\Acl.Infrastructure.csproj" />
<ProjectReference Include="..\..\services\event-subscriber\EventSubscriber.Application\EventSubscriber.Application.csproj" /> <ProjectReference Include="..\..\services\event-subscriber\EventSubscriber.Application\EventSubscriber.Application.csproj" />
<ProjectReference Include="..\..\services\domain\Big.Application\Big.Application.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -0,0 +1,18 @@
# language: en
# Drives S-05 (#6). A zorgprofessional submits a registration; the Domain Service starts the
# registratie process and, via the external-task worker, opens a zaak through the ACL and records
# it on the aggregate (ADR-0009). This scenario exercises the use cases against in-memory stand-ins
# for the Workflow Client and the ACL; real Flowable + ACL + OpenZaak delivery is verified by the
# live-stack check (verify-domain).
Feature: Een registratie indienen
Als zorgprofessional wil ik mijn registratie indienen
zodat er een registratieproces start en een zaak wordt geopend.
Scenario: Indienen start het registratieproces en opent een zaak
Given a zorgprofessional submits a registration for BSN "123456782"
When the domain service handles the submission
Then a registratie process is started for the registration
And the registration has status "INGEDIEND"
When the OpenZaakAanmaken external task is handled for the registration
Then a zaak is opened via the ACL for BSN "123456782"
And the zaak is recorded on the registration

View File

@@ -0,0 +1,54 @@
using Acceptance.Support;
using Big.Application;
using Big.Domain;
using Reqnroll;
using Xunit;
namespace Acceptance.Steps;
/// <summary>Bindings for <c>RegistratieIndienen.feature</c> (S-05). Drives the SubmitRegistration
/// and OpenZaakWorker use cases against in-memory ports; one instance per scenario.</summary>
[Binding]
public sealed class RegistratieIndienenSteps
{
private readonly InMemoryWorkflowClient _workflow = new();
private readonly InMemoryAclClient _acl = new();
private readonly InMemoryRegistrationStore _store = new();
private string _bsn = "";
private RegistrationId _id;
[Given("a zorgprofessional submits a registration for BSN \"(.*)\"")]
public void GivenAZorgprofessionalSubmitsARegistration(string bsn) => _bsn = bsn;
[When("the domain service handles the submission")]
public async Task WhenTheDomainServiceHandlesTheSubmission()
=> _id = await new SubmitRegistration(_store, _workflow).HandleAsync(new SubmitRegistrationCommand(_bsn));
[Then("a registratie process is started for the registration")]
public void ThenARegistratieProcessIsStarted()
=> Assert.Equal(_id, _workflow.StartedFor);
[Then("the registration has status \"(.*)\"")]
public async Task ThenTheRegistrationHasStatus(string expected)
{
var registration = await _store.GetAsync(_id);
Assert.NotNull(registration);
Assert.Equal(expected, registration.Status.ToString().ToUpperInvariant());
Assert.Equal(InMemoryWorkflowClient.StartedProcessInstanceId, registration.ProcessInstanceId);
}
[When("the OpenZaakAanmaken external task is handled for the registration")]
public async Task WhenTheExternalTaskIsHandled()
=> await new OpenZaakWorker(_store, _acl).HandleAsync(new OpenZaakJob("job-acc-1", _id));
[Then("a zaak is opened via the ACL for BSN \"(.*)\"")]
public void ThenAZaakIsOpenedViaTheAcl(string bsn)
=> Assert.Equal(bsn, _acl.OpenedForBsn);
[Then("the zaak is recorded on the registration")]
public async Task ThenTheZaakIsRecordedOnTheRegistration()
{
var registration = await _store.GetAsync(_id);
Assert.Equal(InMemoryAclClient.OpenedZaakUrl, registration!.ZaakUrl);
}
}

View File

@@ -0,0 +1,50 @@
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 Task<Uri> OpenZaakAsync(string bsn, CancellationToken ct = default)
{
OpenedForBsn = bsn;
return Task.FromResult(OpenedZaakUrl);
}
}
/// <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));
}