Failing infrastructure unit tests (stub HttpMessageHandler, fakes): - FlowableWorkflowClient starts a process with the registrationId variable and returns the instance id; acquires OpenZaakAanmaken jobs (topic/workerId/lock) and parses their registrationId; completes a job with the zaakUrl variable — request URIs match flowable-rest's service/ and external-job-api/ paths. - AclHttpClient POSTs the bsn to the ACL and returns the zaak URL. - InMemoryRegistrationStore saves/reads/upserts by id. - OpenZaakJobProcessor acquires, opens a zaak, completes the job; leaves a failing job uncompleted for redelivery; polls harmlessly when idle. Adapters are stubs so the tests compile and fail on their assertions; the green commit implements them against the REST contract verified on a live Flowable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using Big.Application;
|
|
using Big.Domain;
|
|
|
|
namespace Big.Tests;
|
|
|
|
public class OpenZaakWorkerTests
|
|
{
|
|
private static Registration Submitted(string bsn = "123456782")
|
|
{
|
|
var registration = Registration.Submit(bsn);
|
|
registration.RecordProcessStarted("proc-1");
|
|
return registration;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Handling_a_job_opens_a_zaak_via_the_acl_and_attaches_it()
|
|
{
|
|
var registration = Submitted();
|
|
var store = new FakeRegistrationStore();
|
|
store.Seed(registration);
|
|
var acl = new FakeAclClient();
|
|
var worker = new OpenZaakWorker(store, acl);
|
|
|
|
var zaakUrl = await worker.HandleAsync(new OpenZaakJob("job-1", registration.Id));
|
|
|
|
Assert.Equal(FakeAclClient.DefaultZaakUrl, zaakUrl);
|
|
Assert.Equal("123456782", acl.OpenedForBsn);
|
|
var saved = await store.GetAsync(registration.Id);
|
|
Assert.Equal(FakeAclClient.DefaultZaakUrl, saved!.ZaakUrl);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Handling_a_job_for_an_unknown_registration_throws_and_opens_no_zaak()
|
|
{
|
|
var store = new FakeRegistrationStore();
|
|
var acl = new FakeAclClient();
|
|
var worker = new OpenZaakWorker(store, acl);
|
|
|
|
await Assert.ThrowsAsync<InvalidOperationException>(
|
|
() => worker.HandleAsync(new OpenZaakJob("job-1", RegistrationId.New())));
|
|
Assert.Equal(0, acl.CallCount);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Handling_a_redelivered_job_is_idempotent_and_does_not_open_a_second_zaak()
|
|
{
|
|
var registration = Submitted();
|
|
var store = new FakeRegistrationStore();
|
|
store.Seed(registration);
|
|
var acl = new FakeAclClient();
|
|
var worker = new OpenZaakWorker(store, acl);
|
|
var job = new OpenZaakJob("job-1", registration.Id);
|
|
|
|
var first = await worker.HandleAsync(job);
|
|
var second = await worker.HandleAsync(job);
|
|
|
|
Assert.Equal(first, second);
|
|
Assert.Equal(1, acl.CallCount);
|
|
}
|
|
}
|