Skip to content

Commit 1e3cfcb

Browse files
committed
Seed structures and enumerations in LazyClientDataTypeTreeSeed
1 parent 94b3391 commit 1e3cfcb

File tree

2 files changed

+11231
-468
lines changed

2 files changed

+11231
-468
lines changed

opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/typetree/SeededLazyClientDataTypeTreeTest.java

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -120,60 +120,67 @@ void isSubtypeOfWorksForSeededTypes() {
120120
}
121121

122122
@Test
123-
void enumerationBaseTypeIsSeeded() {
123+
void enumerationSubtypesAreSeeded() {
124124
var seededTree =
125125
new LazyClientDataTypeTree(client, LazyClientDataTypeTreeSeed.createSeedTree());
126126

127-
// Enumeration base type is in the seed
127+
// Enumeration and its subtypes are in the seed
128128
assertTrue(seededTree.isResolved(NodeIds.Enumeration));
129-
130-
// Enumeration subtypes are NOT seeded - they require lazy resolution
131-
assertFalse(seededTree.isResolved(NodeIds.NodeClass));
132-
assertFalse(seededTree.isResolved(NodeIds.ServerState));
133-
assertFalse(seededTree.isResolved(NodeIds.RedundancySupport));
129+
assertTrue(seededTree.isResolved(NodeIds.NodeClass));
130+
assertTrue(seededTree.isResolved(NodeIds.ServerState));
131+
assertTrue(seededTree.isResolved(NodeIds.RedundancySupport));
134132
}
135133

136134
@Test
137-
void enumerationSubtypesRequireLazyResolution() {
135+
void seededEnumerationSubtypesHaveDefinitions() {
138136
var seededTree =
139137
new LazyClientDataTypeTree(client, LazyClientDataTypeTreeSeed.createSeedTree());
140138

141-
// Enumeration is in the seed, but NodeClass (a concrete enum subtype) is not
142-
assertTrue(seededTree.isResolved(NodeIds.Enumeration));
143-
assertFalse(seededTree.isResolved(NodeIds.NodeClass));
144-
145-
// Querying NodeClass should trigger lazy resolution
139+
// NodeClass is a seeded enum subtype with an EnumDefinition
146140
DataType nodeClassType = seededTree.getDataType(NodeIds.NodeClass);
147141
assertNotNull(nodeClassType);
148142
assertEquals("NodeClass", nodeClassType.getBrowseName().name());
149-
150-
// Now NodeClass should be resolved
151143
assertTrue(seededTree.isResolved(NodeIds.NodeClass));
152-
153-
// Should have DataTypeDefinition from resolution (enums have EnumDefinition)
154144
assertNotNull(nodeClassType.getDataTypeDefinition());
145+
146+
// ServerState is a seeded enum subtype with an EnumDefinition
147+
DataType serverStateType = seededTree.getDataType(NodeIds.ServerState);
148+
assertNotNull(serverStateType);
149+
assertEquals("ServerState", serverStateType.getBrowseName().name());
150+
assertNotNull(serverStateType.getDataTypeDefinition());
155151
}
156152

157153
@Test
158-
void structureSubtypesRequireLazyResolution() {
154+
void structureSubtypesAreSeeded() {
159155
var seededTree =
160156
new LazyClientDataTypeTree(client, LazyClientDataTypeTreeSeed.createSeedTree());
161157

162-
// Structure is in the seed, but XVType (a concrete structure subtype) is not
158+
// Structure and its subtypes are in the seed
163159
assertTrue(seededTree.isResolved(NodeIds.Structure));
164-
assertFalse(seededTree.isResolved(NodeIds.XVType));
160+
assertTrue(seededTree.isResolved(NodeIds.XVType));
161+
assertTrue(seededTree.isResolved(NodeIds.RolePermissionType));
162+
assertTrue(seededTree.isResolved(NodeIds.StructureDefinition));
163+
}
165164

166-
// Querying XVType should trigger lazy resolution
165+
@Test
166+
void seededStructureSubtypesHaveEncodingIdsAndDefinitions() {
167+
var seededTree =
168+
new LazyClientDataTypeTree(client, LazyClientDataTypeTreeSeed.createSeedTree());
169+
170+
// XVType is a seeded structure subtype with encoding IDs and definition
167171
DataType xvType = seededTree.getDataType(NodeIds.XVType);
168172
assertNotNull(xvType);
169173
assertEquals("XVType", xvType.getBrowseName().name());
170-
171-
// Now XVType should be resolved
172174
assertTrue(seededTree.isResolved(NodeIds.XVType));
173-
174-
// Should have encoding IDs and DataTypeDefinition from resolution
175175
assertNotNull(xvType.getBinaryEncodingId());
176176
assertNotNull(xvType.getDataTypeDefinition());
177+
178+
// RolePermissionType is a seeded structure subtype with encoding IDs and definition
179+
DataType rolePermType = seededTree.getDataType(NodeIds.RolePermissionType);
180+
assertNotNull(rolePermType);
181+
assertEquals("RolePermissionType", rolePermType.getBrowseName().name());
182+
assertNotNull(rolePermType.getBinaryEncodingId());
183+
assertNotNull(rolePermType.getDataTypeDefinition());
177184
}
178185

179186
@Test
@@ -272,11 +279,11 @@ void getBuiltinTypeWorksForSeededTypes() {
272279
}
273280

274281
@Test
275-
void isEnumTypeWorksWithLazyResolution() {
282+
void isEnumTypeWorksForSeededTypes() {
276283
var seededTree =
277284
new LazyClientDataTypeTree(client, LazyClientDataTypeTreeSeed.createSeedTree());
278285

279-
// Enumeration subtypes are not seeded but isEnumType triggers lazy resolution
286+
// Enumeration subtypes are seeded and isEnumType works immediately
280287
assertTrue(seededTree.isEnumType(NodeIds.NodeClass));
281288
assertTrue(seededTree.isEnumType(NodeIds.ServerState));
282289
assertTrue(seededTree.isEnumType(NodeIds.RedundancySupport));
@@ -303,9 +310,8 @@ void isStructTypeWorksForSeededTypes() {
303310
assertFalse(seededTree.isStructType(NodeIds.String));
304311
assertFalse(seededTree.isStructType(NodeIds.Boolean));
305312

306-
// Lazily resolve a concrete struct type and verify isStructType works
307-
DataType xvType = seededTree.getDataType(NodeIds.XVType);
308-
assertNotNull(xvType);
313+
// Seeded structure subtypes can be verified with isStructType immediately
309314
assertTrue(seededTree.isStructType(NodeIds.XVType));
315+
assertTrue(seededTree.isStructType(NodeIds.RolePermissionType));
310316
}
311317
}

0 commit comments

Comments
 (0)