diff --git a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataConditionConfigurationTests.cs b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataConditionConfigurationTests.cs index e2287d40f..486041d0f 100644 --- a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataConditionConfigurationTests.cs +++ b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataConditionConfigurationTests.cs @@ -25,10 +25,21 @@ public sealed class GrpcDataConditionConfigurationTests [Theory] [InlineData(128)] [InlineData(256)] - [InlineData(512)] - public void The_method_bits_stay_unauthorable_until_A2b(int bit) + public void A2b_the_acknowledge_and_confirm_bits_are_authorable(int bit) { var errors = DataConnectionValidator.Validate(GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms | (DataOperations)bit)); + errors.ShouldNotContain(x => x.Code.EndsWith("OperationsInvalid", StringComparison.Ordinal)); + // A mapping may not take a method bit its connection does not grant (mapping ⊆ connection, understood bits). + var wider = GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms); + wider.RemoteNamespaceMappings[0].AllowedOperations = Alarms | (DataOperations)bit; + DataConnectionValidator.Validate(wider).ShouldContain(x => x.Code == "DataMappingOperationsInvalid" && x.Context == "mapping"); + DataConnectionValidator.ValidateDeployed(wider).ShouldContain(x => x.Code == "DataMappingOperationsInvalid"); + } + + [Fact] + public void The_shelve_bit_stays_unauthorable() + { + var errors = DataConnectionValidator.Validate(GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms | DataOperations.AlarmShelve)); errors.ShouldContain(x => x.Code == "DataConnectionOperationsInvalid"); errors.ShouldContain(x => x.Code == "DataExportOperationsInvalid"); errors.ShouldContain(x => x.Code == "DataMappingOperationsInvalid"); @@ -102,20 +113,21 @@ public sealed class GrpcDataConditionConfigurationTests } [Fact] - public void AllowGalaxyServiceAck_requires_AlarmAcknowledge_so_it_cannot_be_authored_before_A2b() + public void AllowGalaxyServiceAck_is_valid_only_with_AlarmAcknowledge() { var draft = GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms); DataConnectionValidator.Validate(draft).ShouldNotContain(x => x.Code == "DataExportGalaxyAckInvalid"); draft.DataExports[0].AllowGalaxyServiceAck = true; DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataExportGalaxyAckInvalid" && x.Context == "export"); DataConnectionValidator.ValidateDeployed(draft).ShouldContain(x => x.Code == "DataExportGalaxyAckInvalid" && x.Context == "export"); - // With the acknowledge grant: authoring still refuses the (A2b) bit itself, but not the flag; a deployed row from a - // newer central carrying both is tolerated (the bit is ignored, the flag is inert). + // A2b: with the acknowledge grant both the bit and the flag author and deploy cleanly. draft.DataExports[0].AllowedOperations = Alarms | DataOperations.AlarmAcknowledge; var authored = DataConnectionValidator.Validate(draft); - authored.ShouldContain(x => x.Code == "DataExportOperationsInvalid"); - authored.ShouldNotContain(x => x.Code == "DataExportGalaxyAckInvalid"); + authored.ShouldNotContain(x => x.Code == "DataExportOperationsInvalid" || x.Code == "DataExportGalaxyAckInvalid"); DataConnectionValidator.ValidateDeployed(draft).ShouldNotContain(x => x.Code == "DataExportOperationsInvalid" || x.Code == "DataExportGalaxyAckInvalid"); + // Confirm alone does not qualify the opt-in. + draft.DataExports[0].AllowedOperations = Alarms | DataOperations.AlarmConfirm; + DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataExportGalaxyAckInvalid"); } [Fact] @@ -145,6 +157,8 @@ public sealed class GrpcDataConditionConfigurationTests DataConnectionValidator.ConditionCapacityWarnings(draft, 200_000).ShouldBeEmpty(); DataConnectionValidator.ConditionCapacityWarnings(draft, 49_000).Count.ShouldBe(1, "node-b at exactly the cap is not over it"); DataConnectionValidator.ConditionCapacityWarnings(draft, 48_999).Count.ShouldBe(2); + // A2b: the deploy gate logs the same rule, non-blocking (AdminOperationsActor.StartDeployment). + DataConnectionValidator.DeployWarnings(draft).ShouldHaveSingleItem().ShouldStartWith("[DataConditionCapacityWarning] Consumer node node-a"); } [Fact] diff --git a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataReservedOperationAuthoringTests.cs b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataReservedOperationAuthoringTests.cs index ad4dfc86f..942ed82ad 100644 --- a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataReservedOperationAuthoringTests.cs +++ b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataReservedOperationAuthoringTests.cs @@ -13,9 +13,9 @@ namespace ZB.MOM.WW.OtOpcUa.Configuration.Tests.DataConnections; [Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "X0")] public sealed class GrpcDataReservedOperationAuthoringTests { - // H2 implemented 32 (HistoryRead) and A2a 64 (AlarmSubscribe): authoring accepts them (GrpcDataHistoryConfigurationTests, - // GrpcDataConditionConfigurationTests). A2b takes the method bits. - public static TheoryData ReservedBits => new(128, 256, 512); + // H2 implemented 32 (HistoryRead), A2a 64 (AlarmSubscribe), A2b 128/256 (AlarmAcknowledge/AlarmConfirm): authoring accepts + // them (GrpcDataHistoryConfigurationTests, GrpcDataConditionConfigurationTests). 512 (AlarmShelve) stays reserved. + public static TheoryData ReservedBits => new(512); [Theory] [MemberData(nameof(ReservedBits))]