feat(notif-outbox): add SourceNode to Notification entity + NotificationSubmit
This commit is contained in:
@@ -51,6 +51,20 @@ public class NotificationEntityTests
|
||||
Assert.Equal(parentExecutionId, n.OriginParentExecutionId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SourceNode_DefaultsToNull_AndIsSettable()
|
||||
{
|
||||
// SourceNode identifies the cluster node that emitted the notification
|
||||
// (site node-a/node-b or central-a/central-b). Additive nullable
|
||||
// property — defaults to null on rows submitted before the column
|
||||
// existed, and round-trips its value when set.
|
||||
var n = new Notification("id-1", NotificationType.Email, "ops-team", "subj", "body", "SiteA");
|
||||
Assert.Null(n.SourceNode);
|
||||
|
||||
n.SourceNode = "node-a";
|
||||
Assert.Equal("node-a", n.SourceNode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullArguments_Throw()
|
||||
{
|
||||
|
||||
@@ -126,6 +126,32 @@ public class NotificationMessagesTests
|
||||
Assert.Equal(parentExecutionId, roundTripped!.OriginParentExecutionId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotificationSubmit_carries_SourceNode()
|
||||
{
|
||||
// SourceNode is an additive trailing member — old call sites and old
|
||||
// serialized payloads leave it null. When supplied it round-trips
|
||||
// through both construction and JSON (the buffered S&F payload IS a
|
||||
// serialized NotificationSubmit).
|
||||
var defaulted = new NotificationSubmit(
|
||||
"notif-9", "Operators", "Subject", "Body",
|
||||
"site-01", "inst-1", "OnAlarm", DateTimeOffset.UtcNow);
|
||||
Assert.Null(defaulted.SourceNode);
|
||||
|
||||
var stamped = new NotificationSubmit(
|
||||
"notif-10", "Operators", "Subject", "Body",
|
||||
"site-01", "inst-1", "OnAlarm", DateTimeOffset.UtcNow,
|
||||
OriginExecutionId: null,
|
||||
OriginParentExecutionId: null,
|
||||
SourceNode: "node-a");
|
||||
Assert.Equal("node-a", stamped.SourceNode);
|
||||
|
||||
var json = System.Text.Json.JsonSerializer.Serialize(stamped);
|
||||
var roundTripped = System.Text.Json.JsonSerializer.Deserialize<NotificationSubmit>(json);
|
||||
Assert.NotNull(roundTripped);
|
||||
Assert.Equal("node-a", roundTripped!.SourceNode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotificationSubmit_ValueEquality_EqualWhenAllFieldsMatch()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user