On each notification the subscriber reads the zaak's reference (identificatie) through the ACL — the only code allowed to talk to ZGW (§8.1) — and persists it on the register_projection row and in the processed_notifications replay log. Storing it in the log keeps rebuild log-only (ADR-0008): no ACL/ZGW access on rebuild. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using Acceptance.Support;
|
|
using EventSubscriber.Application;
|
|
using Reqnroll;
|
|
using Xunit;
|
|
|
|
namespace Acceptance.Steps;
|
|
|
|
/// <summary>Bindings for <c>RegisterProjectieBijwerken.feature</c> (S-06). Reqnroll creates
|
|
/// one instance per scenario, so instance fields hold scenario-scoped state.</summary>
|
|
[Binding]
|
|
public sealed class RegisterProjectieBijwerkenSteps
|
|
{
|
|
private const string ZaakBase = "http://openzaak:8000/zaken/api/v1/zaken/";
|
|
|
|
private readonly InMemoryNotificationLog _log = new();
|
|
private readonly InMemoryProjectionStore _store = new();
|
|
private readonly NotificationProjector _projector;
|
|
private Notification? _notification;
|
|
|
|
public RegisterProjectieBijwerkenSteps()
|
|
=> _projector = new NotificationProjector(_log, _store, new InMemoryAclReferenceClient());
|
|
|
|
[Given("a zaak is created in OpenZaak with id \"(.*)\"")]
|
|
public void GivenAZaakIsCreatedInOpenZaakWithId(string id)
|
|
=> _notification = new Notification("zaken", "zaak", "create", new Uri(ZaakBase + id));
|
|
|
|
[When("the NRC notification for that zaak is delivered to the event subscriber")]
|
|
public Task WhenTheNotificationIsDelivered()
|
|
=> _projector.HandleAsync(_notification!);
|
|
|
|
[When("the same NRC notification is delivered again")]
|
|
public Task WhenTheSameNotificationIsDeliveredAgain()
|
|
=> _projector.HandleAsync(_notification!);
|
|
|
|
[Then("the register projection contains a row for \"(.*)\" with status \"(.*)\"")]
|
|
public async Task ThenTheProjectionContainsARowWithStatus(string id, string status)
|
|
{
|
|
var entry = Assert.Single(await _store.AllAsync());
|
|
Assert.Equal(id, entry.Id);
|
|
Assert.Equal(status, entry.Status);
|
|
}
|
|
|
|
[Then("the register projection contains exactly one row for \"(.*)\"")]
|
|
public async Task ThenTheProjectionContainsExactlyOneRowFor(string id)
|
|
{
|
|
await _store.AllAsync();
|
|
Assert.Single(_store.RowsFor(id));
|
|
}
|
|
}
|