test(event-subscriber): project zaak-created notifications into the read projection (refs #7)
Failing unit + acceptance tests for the Event Subscriber's NotificationProjector: a zaken/zaak/create notification yields one INGEDIEND projection row, duplicate deliveries collapse to one row, non-zaak/non-create notifications are ignored, and a rebuild repopulates the projection from the durable notification log (PRD §8.4). The projector is a no-op stub so the tests compile and fail on the assertions; the implementation follows in the green commit. The notification log doubles as the idempotency guard and rebuild source so a rebuild needs no OpenZaak access (§8.1). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
48
tests/acceptance/Steps/RegisterProjectieBijwerkenSteps.cs
Normal file
48
tests/acceptance/Steps/RegisterProjectieBijwerkenSteps.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
|
||||
[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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user