From 51cda2c74476ea1be815392741b8422738b77f73 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 14 Jun 2026 22:41:43 -0400 Subject: [PATCH] test(alarms): assert OperatorComment flows through ForwardNativeAlarm --- .../DriverHostActorNativeAlarmTests.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverHostActorNativeAlarmTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverHostActorNativeAlarmTests.cs index 32553578..884fa318 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverHostActorNativeAlarmTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverHostActorNativeAlarmTests.cs @@ -188,6 +188,44 @@ public sealed class DriverHostActorNativeAlarmTests : RuntimeActorTestBase alerts.ExpectNoMsg(TimeSpan.FromMilliseconds(500)); } + /// A native alarm whose AlarmEventArgs.OperatorComment is set flows through + /// DriverHostActor.ForwardNativeAlarm into the published : + /// Comment carries the operator string and User is "device" (a non-null comment + /// signals the upstream alarm system provided an operator origin, but without a specific user identity). + /// + [Fact] + public void Native_alarm_operator_comment_flows_to_transition_event() + { + var db = NewInMemoryDbFactory(); + var deploymentId = SeedDeploymentWithAlarmTag(db, RevA, + Equip: "eq-1", Driver: "drv-1", FullName: "Temp.HiHi", Folder: null, Name: "temp_hi"); + + var alerts = CreateTestProbe(); + SubscribeToAlerts(alerts); + + var (actor, publish) = SpawnHostAndApply(db, deploymentId); + + // Send an alarm whose OperatorComment is set — simulates an upstream acknowledge-with-comment. + actor.Tell(new DriverInstanceActor.AttributeAlarmPublished("drv-1", new AlarmEventArgs( + new StubAlarmHandle(), + SourceNodeId: "Temp", + ConditionId: "Temp.HiHi", + AlarmType: "OffNormalAlarm", + Message: "investigating", + Severity: AlarmSeverity.High, + SourceTimestampUtc: Ts, + Kind: AlarmTransitionKind.Acknowledge, + OperatorComment: "investigating"))); + + // OPC UA condition update is ungated — drain it. + publish.ExpectMsg(TimeSpan.FromSeconds(5)); + + // The published AlarmTransitionEvent must carry the comment + the "device" user marker. + var evt = alerts.ExpectMsg(TimeSpan.FromSeconds(5)); + evt.Comment.ShouldBe("investigating"); + evt.User.ShouldBe("device"); + } + /// Subscribe to the alerts DPS topic and wait for the ack. /// The Subscribe is sent FROM the probe so the SubscribeAck returns to it. Mirrors the /// ScriptedAlarmHostActor test harness.