feat(workflow): emit diplomaOrigin start variable + accept it on submit (S-13, refs #14)
The Workflow Client now posts diplomaOrigin alongside registrationId when starting the process, and the domain submit endpoint accepts an optional diplomaOrigin (defaulting to domestic) so a foreign submission can be driven end-to-end. Adds the aggregate + submit-forwarding tests now that the plumbing is in place. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,12 @@ app.MapGet("/health", () => "Healthy");
|
|||||||
// a location to read the registration's progress (ADR-0009, eventual consistency).
|
// a location to read the registration's progress (ADR-0009, eventual consistency).
|
||||||
app.MapPost("/registrations", async (SubmitRegistrationRequest body, SubmitRegistration submit, CancellationToken ct) =>
|
app.MapPost("/registrations", async (SubmitRegistrationRequest body, SubmitRegistration submit, CancellationToken ct) =>
|
||||||
{
|
{
|
||||||
var id = await submit.HandleAsync(new SubmitRegistrationCommand(body.Bsn), ct);
|
// Diploma origin defaults to domestic; a foreign (eIDAS) submission passes "Buitenlands" so the
|
||||||
|
// workflow's DMN routes it through CBGV-advies (S-13). An unknown value is a bad request.
|
||||||
|
if (!Enum.TryParse<DiplomaOrigin>(body.DiplomaOrigin, ignoreCase: true, out var origin) && body.DiplomaOrigin is not null)
|
||||||
|
return Results.BadRequest(new { error = $"Unknown diplomaOrigin '{body.DiplomaOrigin}'. Expected 'Binnenlands' or 'Buitenlands'." });
|
||||||
|
|
||||||
|
var id = await submit.HandleAsync(new SubmitRegistrationCommand(body.Bsn, origin), ct);
|
||||||
return Results.Accepted($"/registrations/{id}", new RegistrationResponse(id.ToString(), RegistrationStatus.Ingediend.ToString(), null));
|
return Results.Accepted($"/registrations/{id}", new RegistrationResponse(id.ToString(), RegistrationStatus.Ingediend.ToString(), null));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -117,7 +122,7 @@ app.MapGet("/registrations/{id}", async (string id, IRegistrationStore store, Ca
|
|||||||
|
|
||||||
await app.RunAsync();
|
await app.RunAsync();
|
||||||
|
|
||||||
public sealed record SubmitRegistrationRequest(string Bsn);
|
public sealed record SubmitRegistrationRequest(string Bsn, string? DiplomaOrigin = null);
|
||||||
|
|
||||||
public sealed record DecideRequest(string Besluit);
|
public sealed record DecideRequest(string Besluit);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public sealed class FlowableWorkflowClient(HttpClient http, FlowableOptions opti
|
|||||||
private const string BehandelaarGroup = "behandelaar";
|
private const string BehandelaarGroup = "behandelaar";
|
||||||
private const string TeamleadGroup = "teamlead";
|
private const string TeamleadGroup = "teamlead";
|
||||||
private const string RegistrationIdVariable = "registrationId";
|
private const string RegistrationIdVariable = "registrationId";
|
||||||
|
private const string DiplomaOriginVariable = "diplomaOrigin";
|
||||||
private const string ZaakUrlVariable = "zaakUrl";
|
private const string ZaakUrlVariable = "zaakUrl";
|
||||||
private const string BesluitVariable = "besluit";
|
private const string BesluitVariable = "besluit";
|
||||||
private const string IngetrokkenMessage = "RegistratieIngetrokken";
|
private const string IngetrokkenMessage = "RegistratieIngetrokken";
|
||||||
@@ -33,7 +34,10 @@ public sealed class FlowableWorkflowClient(HttpClient http, FlowableOptions opti
|
|||||||
{
|
{
|
||||||
var request = new StartProcessRequest(
|
var request = new StartProcessRequest(
|
||||||
ProcessDefinitionKey,
|
ProcessDefinitionKey,
|
||||||
[new Variable(RegistrationIdVariable, "string", registrationId.ToString())]);
|
[
|
||||||
|
new Variable(RegistrationIdVariable, "string", registrationId.ToString()),
|
||||||
|
new Variable(DiplomaOriginVariable, "string", diplomaOrigin.ToString()),
|
||||||
|
]);
|
||||||
|
|
||||||
var created = await PostAsync<StartProcessRequest, ProcessInstance>(
|
var created = await PostAsync<StartProcessRequest, ProcessInstance>(
|
||||||
"service/runtime/process-instances", request, ct)
|
"service/runtime/process-instances", request, ct)
|
||||||
|
|||||||
@@ -16,6 +16,15 @@ public class RegistrationTests
|
|||||||
Assert.Null(registration.ProcessInstanceId);
|
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]
|
[Theory]
|
||||||
[InlineData("")]
|
[InlineData("")]
|
||||||
[InlineData(" ")]
|
[InlineData(" ")]
|
||||||
|
|||||||
@@ -25,6 +25,19 @@ public class SubmitRegistrationTests
|
|||||||
Assert.Equal(2, store.SaveCount);
|
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]
|
[Fact]
|
||||||
public async Task Rejects_a_null_command_without_touching_the_store_or_workflow()
|
public async Task Rejects_a_null_command_without_touching_the_store_or_workflow()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user