feat(grpc-data): A2a AdminUI AlarmSubscribe checkbox, condition limit fields, capacity warning
Connection/export/mapping editors offer AlarmSubscribe (DataOperationAuthoring; method bits stay unauthorable until A2b); export MaxConditions and mapping MaxConditions / ConditionStale / ConditionMethod / ConditionSnapshot timeouts with the validator's min/max; the X0 banner already shows for any post-v1 bit. The Mappings panel lists the validator's non-blocking ConditionCapacityWarnings for this cluster's consumer nodes. AllowGalaxyServiceAck is not in the UI (A2b).
This commit is contained in:
+81
@@ -0,0 +1,81 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Entities;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Validation;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.DataConnections;
|
||||
|
||||
/// <summary>A2 editor models: the AlarmSubscribe checkbox, the condition limits' defaults, the X0 banner and the capacity warning.</summary>
|
||||
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "A2")]
|
||||
public sealed class GrpcDataConditionEditorTests
|
||||
{
|
||||
[Fact]
|
||||
public void AlarmSubscribe_is_authorable_and_the_method_bits_are_not()
|
||||
{
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldContain(DataOperations.AlarmSubscribe);
|
||||
foreach (var bit in new[] { DataOperations.AlarmAcknowledge, DataOperations.AlarmConfirm, DataOperations.AlarmShelve })
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(bit, "A2b");
|
||||
// Every authorable bit is one the validator accepts and the node understands.
|
||||
var all = DataOperationAuthoring.AuthorableOperations.Aggregate(DataOperations.None, (a, b) => a | b);
|
||||
(all & ~DataOperationSets.Understood).ShouldBe(DataOperations.None);
|
||||
// (Write is left out only because a Write mapping also needs write-through, which the minimal draft does not set.)
|
||||
DataConnectionValidator.Validate(GrpcDataEditorValidationTestsAccess.ValidSnapshot(all & ~DataOperations.Write))
|
||||
.ShouldNotContain(x => x.Code.EndsWith("OperationsInvalid", StringComparison.Ordinal));
|
||||
DataOperationAuthoring.Label(DataOperations.AlarmSubscribe).ShouldBe("AlarmSubscribe");
|
||||
new DataConnectionEditorModel().Value.AllowedOperations.HasFlag(DataOperations.AlarmSubscribe).ShouldBeFalse();
|
||||
new RemoteMappingEditorModel().Value.AllowedOperations.HasFlag(DataOperations.AlarmSubscribe).ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void New_drafts_carry_the_plans_condition_limits_and_no_Galaxy_ack()
|
||||
{
|
||||
var mapping = new RemoteMappingEditorModel().Value;
|
||||
(mapping.MaxConditions, mapping.ConditionStaleTimeoutMilliseconds, mapping.ConditionMethodTimeoutMilliseconds,
|
||||
mapping.ConditionSnapshotTimeoutMilliseconds).ShouldBe((1000, 30000, 5000, 30000));
|
||||
var export = new DataExport();
|
||||
export.MaxConditions.ShouldBe(1000);
|
||||
export.AllowGalaxyServiceAck.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_X0_banner_shows_while_AlarmSubscribe_is_ticked()
|
||||
{
|
||||
var banner = DataOperationAuthoring.FeatureBitBanner(DataOperations.Read | DataOperations.AlarmSubscribe).ShouldNotBeNull();
|
||||
banner.ShouldContain("every node of both clusters must run X0+ before authoring this", Case.Insensitive);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_AlarmSubscribe_draft_validates_and_an_out_of_range_condition_limit_does_not()
|
||||
{
|
||||
var draft = GrpcDataEditorValidationTestsAccess.ValidSnapshot(DataOperations.Read | DataOperations.AlarmSubscribe);
|
||||
DataConnectionValidator.Validate(draft).ShouldNotContain(x => x.Code.EndsWith("LimitInvalid", StringComparison.Ordinal));
|
||||
draft.RemoteNamespaceMappings[0].MaxConditions = DataConnectionValidator.MaxConditionsLimit + 1;
|
||||
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataMappingLimitInvalid");
|
||||
draft.RemoteNamespaceMappings[0].MaxConditions = 1000;
|
||||
draft.DataExports[0].MaxConditions = 0;
|
||||
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataExportLimitInvalid");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_capacity_warning_lists_only_this_clusters_over_cap_consumer_nodes()
|
||||
{
|
||||
RemoteNamespaceMapping Mapping(string id, string cluster, string node) => new()
|
||||
{
|
||||
RemoteNamespaceMappingId = id, ClusterId = cluster, Enabled = true, ConsumerNodeIds = [node], MaxConditions = 5000,
|
||||
AllowedOperations = DataOperations.Read | DataOperations.AlarmSubscribe,
|
||||
};
|
||||
var snapshot = new DraftSnapshot
|
||||
{
|
||||
GenerationId = 1, ClusterId = "MAIN",
|
||||
ClusterNodes = [new() { NodeId = "main-1", ClusterId = "MAIN", Host = "h", ApplicationUri = "urn:a", CreatedBy = "t" }, new() { NodeId = "other-1", ClusterId = "OTHER", Host = "h", ApplicationUri = "urn:b", CreatedBy = "t" }],
|
||||
// 5000 × 49 = 245,000 > 122,500 for each node.
|
||||
RemoteNamespaceMappings = [Mapping("m", "MAIN", "main-1"), Mapping("o", "OTHER", "other-1")],
|
||||
};
|
||||
var warning = DataOperationAuthoring.ConditionCapacityWarnings(snapshot, "main").ShouldHaveSingleItem();
|
||||
warning.ShouldContain("main-1");
|
||||
warning.ShouldContain("MaxImportedConditionNodes");
|
||||
DataOperationAuthoring.ConditionCapacityWarnings(snapshot, "none").ShouldBeEmpty();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -14,7 +14,8 @@ public sealed class GrpcDataHistoryEditorTests
|
||||
public void HistoryRead_is_authorable_and_new_drafts_do_not_grant_it()
|
||||
{
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldContain(DataOperations.HistoryRead);
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(DataOperations.AlarmSubscribe, "A2 bits stay unauthorable");
|
||||
// A2a made AlarmSubscribe authorable (GrpcDataConditionEditorTests); the method bits stay unauthorable until A2b.
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(DataOperations.AlarmAcknowledge, "A2b bits stay unauthorable");
|
||||
// Every authorable bit is one the validator accepts — the editor never gets ahead of authoring.
|
||||
var all = DataOperationAuthoring.AuthorableOperations.Aggregate(DataOperations.None, (a, b) => a | b);
|
||||
(all & ~DataOperationSets.Understood).ShouldBe(DataOperations.None);
|
||||
|
||||
Reference in New Issue
Block a user