Builds the four-seam, three-write-path reference demo backend: case-framework (seam D stand-in), legacy-backend/frontend (SQL Server, seams A/B/C targets), and new-backend (Domain/Application/Infrastructure.*/Api implementing the source resolver, take/release-ownership, write-through translator, and owned assessment flow), wired together via docker-compose with a plain placeholder frontend standing in for the Angular portal until Session 2. All 11 Architecture.Tests pass and scripts/smoke.sh passes end-to-end against a fresh `docker compose up`, covering acceptance criteria 1-3 and 7-22. Fixes two real domain bugs found only once the stack ran for real: the BSN eleven-proof checksum trivially passes all-zero digits, and the adoption mapper silently treated a partial legacy address as absent instead of failing loudly. Also fixes several environment-specific integration issues (rootless Podman/SELinux bind-mount permissions, a buildah NuGet layer-caching bug, SqlClient's invariant-globalization incompatibility, and an nginx path-prefix mismatch for the legacy frontend). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
102 lines
4.0 KiB
C#
102 lines
4.0 KiB
C#
namespace New.Domain.ValueObjects;
|
|
|
|
/// <summary>
|
|
/// The decision on an application. Named <c>AssessmentOutcome</c> - never the
|
|
/// bare word "Status" - to keep it distinct from the case-framework's own
|
|
/// <c>ProcessStatus</c> and from the legacy `stat_cd` / `beoordRes` codes.
|
|
/// Also stands in for what the case-framework calls a "Decision" document.
|
|
/// </summary>
|
|
public enum AssessmentOutcome
|
|
{
|
|
Approved,
|
|
Rejected,
|
|
}
|
|
|
|
/// <summary>
|
|
/// A recorded assessment of a <see cref="RegistrationApplication"/>. Only ever
|
|
/// constructed through <see cref="Create"/>, which enforces every invariant
|
|
/// so the same validation applies whether the assessment is entered natively
|
|
/// through the owned path or reconstructed from legacy data during adoption.
|
|
/// </summary>
|
|
public sealed record Assessment
|
|
{
|
|
private const int DefaultMinimumMotivationLength = 20;
|
|
private const int OtherCategoryMinimumMotivationLength = 50;
|
|
|
|
public AssessmentOutcome Outcome { get; }
|
|
public string Motivation { get; }
|
|
public IReadOnlyList<string> VerifiedItems { get; }
|
|
public string? ExceptionReason { get; }
|
|
public string? RejectionCategory { get; }
|
|
public DateOnly DecidedOn { get; }
|
|
|
|
private Assessment(
|
|
AssessmentOutcome outcome,
|
|
string motivation,
|
|
IReadOnlyList<string> verifiedItems,
|
|
string? exceptionReason,
|
|
string? rejectionCategory,
|
|
DateOnly decidedOn)
|
|
{
|
|
Outcome = outcome;
|
|
Motivation = motivation;
|
|
VerifiedItems = verifiedItems;
|
|
ExceptionReason = exceptionReason;
|
|
RejectionCategory = rejectionCategory;
|
|
DecidedOn = decidedOn;
|
|
}
|
|
|
|
public static Assessment Create(
|
|
AssessmentOutcome outcome,
|
|
string motivation,
|
|
IReadOnlyList<string>? verifiedItems,
|
|
string? exceptionReason,
|
|
string? rejectionCategory,
|
|
DateOnly decidedOn)
|
|
{
|
|
var items = verifiedItems ?? Array.Empty<string>();
|
|
|
|
// Recording an assessment requires either every diploma evidence item
|
|
// to have been verified, or a recorded reason why verification was
|
|
// skipped - never neither.
|
|
if (items.Count == 0 && string.IsNullOrWhiteSpace(exceptionReason))
|
|
{
|
|
throw new DomainInvariantViolationException(
|
|
"Assessment.VerificationRequired",
|
|
"Recording an assessment requires either at least one verified item or a recorded exception reason.");
|
|
}
|
|
|
|
// rejectionCategory only makes sense - and is only carried - alongside
|
|
// a Rejected outcome.
|
|
var normalizedRejectionCategory = outcome == AssessmentOutcome.Rejected
|
|
? rejectionCategory
|
|
: null;
|
|
|
|
if (outcome == AssessmentOutcome.Rejected && string.IsNullOrWhiteSpace(normalizedRejectionCategory))
|
|
{
|
|
throw new DomainInvariantViolationException(
|
|
"Assessment.RejectionCategoryRequired",
|
|
"A rejection category is required when the outcome is Rejected.");
|
|
}
|
|
|
|
var minimumLength = IsOtherCategory(normalizedRejectionCategory)
|
|
? OtherCategoryMinimumMotivationLength
|
|
: DefaultMinimumMotivationLength;
|
|
|
|
if (string.IsNullOrWhiteSpace(motivation) || motivation.Trim().Length < minimumLength)
|
|
{
|
|
throw new DomainInvariantViolationException(
|
|
"Assessment.MotivationTooShort",
|
|
$"The motivation must be at least {minimumLength} characters long" +
|
|
(IsOtherCategory(normalizedRejectionCategory) ? " when the rejection category is 'Other'." : "."));
|
|
}
|
|
|
|
return new Assessment(outcome, motivation, items, exceptionReason, normalizedRejectionCategory, decidedOn);
|
|
}
|
|
|
|
private static bool IsOtherCategory(string? rejectionCategory) =>
|
|
rejectionCategory is not null &&
|
|
(string.Equals(rejectionCategory, "Other", StringComparison.OrdinalIgnoreCase) ||
|
|
string.Equals(rejectionCategory, "anders", StringComparison.OrdinalIgnoreCase));
|
|
}
|