test(domain): a citizen can withdraw an open registration → INGETROKKEN (refs #12)
Withdraw is allowed from INGEDIEND or IN_BEHANDELING, needs no zaak, is idempotent, and is rejected once the registration has been decided (INGESCHREVEN/AFGEWEZEN). The WithdrawRegistration handler loads, withdraws, and persists; a repeated withdrawal is a no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -217,4 +217,72 @@ public class RegistrationTests
|
||||
Assert.Contains("Afgewezen", rejectEx.Message);
|
||||
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Withdrawing_an_ingediend_registration_sets_it_ingetrokken()
|
||||
{
|
||||
var registration = Registration.Submit("123456782");
|
||||
|
||||
registration.Withdraw();
|
||||
|
||||
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Withdrawing_an_in_behandeling_registration_sets_it_ingetrokken()
|
||||
{
|
||||
// A citizen can still pull a registration back while a behandelaar has it in behandeling.
|
||||
var registration = Registration.Submit("123456782");
|
||||
registration.TakeIntoBehandeling();
|
||||
|
||||
registration.Withdraw();
|
||||
|
||||
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Withdrawing_needs_no_zaak()
|
||||
{
|
||||
// Withdrawal is the citizen's own action and does not depend on the zaak having been opened.
|
||||
var registration = Registration.Submit("123456782");
|
||||
|
||||
registration.Withdraw();
|
||||
|
||||
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
||||
Assert.Null(registration.ZaakUrl);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Re_withdrawing_an_already_ingetrokken_registration_is_idempotent()
|
||||
{
|
||||
var registration = Registration.Submit("123456782");
|
||||
registration.Withdraw();
|
||||
|
||||
registration.Withdraw();
|
||||
|
||||
Assert.Equal(RegistrationStatus.Ingetrokken, registration.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Withdrawing_an_approved_registration_is_rejected()
|
||||
{
|
||||
var registration = Registration.Submit("123456782");
|
||||
registration.AttachZaak(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
||||
registration.Approve();
|
||||
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => registration.Withdraw());
|
||||
Assert.Contains("only an INGEDIEND", ex.Message);
|
||||
Assert.Equal(RegistrationStatus.Ingeschreven, registration.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Withdrawing_a_rejected_registration_is_rejected()
|
||||
{
|
||||
var registration = Registration.Submit("123456782");
|
||||
registration.Reject();
|
||||
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => registration.Withdraw());
|
||||
Assert.Contains("only an INGEDIEND", ex.Message);
|
||||
Assert.Equal(RegistrationStatus.Afgewezen, registration.Status);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user