2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14 import java.io.FileNotFoundException;
16 import java.net.URISyntaxException;
17 import java.text.DateFormat;
18 import java.text.ParseException;
19 import java.text.SimpleDateFormat;
20 import java.util.ArrayDeque;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.Deque;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.opendaylight.yangtools.yang.common.QName;
28 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
29 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
30 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
31 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
32 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
33 import org.opendaylight.yangtools.yang.model.api.Module;
34 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
35 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
36 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
37 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
38 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
39 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
40 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
41 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
43 public class UsesAugmentTest {
44 private static final URI UG_NS = URI.create("urn:opendaylight:params:xml:ns:yang:uses-grouping");
45 private static final URI GD_NS = URI.create("urn:opendaylight:params:xml:ns:yang:grouping-definitions");
49 private Set<Module> modules;
52 public void init() throws FileNotFoundException, ParseException {
53 DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
54 UG_REV = simpleDateFormat.parse("2013-07-30");
55 GD_REV = simpleDateFormat.parse("2013-09-04");
59 * Structure of testing model:
62 * |-- leaf version (U)
65 * |-- |-- container rp
66 * |-- |-- |-- leaf priority (U)
67 * |-- |-- |-- container box (U)
68 * |-- |-- |-- |-- container order (A)
69 * |-- |-- |-- |-- |-- leaf delete (U)
70 * |-- |-- |-- |-- |-- |-- leaf setup (U)
71 * |-- |-- |-- leaf processing-rule (U)
72 * |-- |-- |-- leaf ignore (U)
73 * |-- |-- path-key-expansion
74 * |-- |-- |-- container path-key
75 * |-- |-- |-- |-- list path-keys (U)
76 * |-- |-- |-- |-- |-- leaf version (U)
77 * |-- |-- |-- |-- |-- leaf type (U)
78 * |-- |-- |-- |-- |-- leaf processing-rule (U)
79 * |-- |-- |-- |-- |-- leaf ignore (U)
80 * |-- |-- container segment-computation
81 * |-- |-- |-- container p2p
82 * |-- |-- |-- |-- container endpoints
83 * |-- |-- |-- |-- |-- leaf processing-rule (U)
84 * |-- |-- |-- |-- |-- leaf ignore (U)
85 * |-- |-- |-- |-- |-- container box (U)
86 * |-- |-- |-- |-- |-- choice address-family (U)
87 * |-- |-- |-- |-- |-- |-- case ipv4
88 * |-- |-- |-- |-- |-- |-- |-- leaf source-ipv4-address
89 * |-- |-- |-- |-- |-- |-- case ipv6
90 * |-- |-- |-- |-- |-- |-- |-- leaf source-ipv6-address
91 * |-- |-- |-- |-- container reported-route
92 * |-- |-- |-- |-- |-- container bandwidth
93 * |-- |-- |-- |-- |-- list subobjects(U)
94 * |-- |-- |-- |-- |-- leaf processing-rule (U)
95 * |-- |-- |-- |-- |-- leaf ignore (U)
96 * |-- |-- |-- |-- container bandwidth (U)
97 * |-- |-- |-- |-- |-- container bandwidth (U)
98 * |-- |-- |-- |-- |-- leaf processing-rule (U)
99 * |-- |-- |-- |-- |-- leaf ignore (U)
101 * |-- |-- list metric
102 * |-- |-- |-- leaf metric-type (U)
103 * |-- |-- |-- container box (U)
104 * |-- |-- |-- leaf processing-rule (U)
105 * |-- |-- |-- leaf ignore (U)
106 * |-- |-- leaf link-diverse (U)
107 * |-- |-- leaf processing-rule (U)
108 * |-- |-- leaf ignore (U)
110 * U = added by uses A = added by augment
112 * @throws Exception if exception occurs
115 public void testAugmentInUses() throws Exception {
116 modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
117 Module testModule = TestUtils.findModule(modules, "uses-grouping");
119 Deque<QName> path = new ArrayDeque<>();
121 // * notification pcreq
122 Set<NotificationDefinition> notifications = testModule.getNotifications();
123 assertEquals(1, notifications.size());
124 NotificationDefinition pcreq = notifications.iterator().next();
125 assertNotNull(pcreq);
126 QName expectedQName = QName.create(UG_NS, UG_REV, "pcreq");
127 path.offer(expectedQName);
128 SchemaPath expectedPath = SchemaPath.create(path, true);
129 assertEquals(expectedPath, pcreq.getPath());
130 Collection<DataSchemaNode> childNodes = pcreq.getChildNodes();
131 assertEquals(4, childNodes.size());
132 // * |-- leaf version
133 LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName("version");
134 assertNotNull(version);
135 expectedQName = QName.create(UG_NS, UG_REV, "version");
136 path.offer(expectedQName);
137 expectedPath = SchemaPath.create(path, true);
138 assertEquals(expectedPath, version.getPath());
139 expectedQName = QName.create(UG_NS, UG_REV, "version");
140 path.offer(expectedQName);
141 expectedPath = SchemaPath.create(true, pcreq.getQName(), expectedQName);
142 assertEquals(expectedPath, version.getType().getPath());
143 assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
144 assertTrue(version.isAddedByUses());
146 LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName("type");
148 expectedQName = QName.create(UG_NS, UG_REV, "type");
149 assertTrue(type.isAddedByUses());
152 path.offer(expectedQName);
153 expectedPath = SchemaPath.create(path, true);
154 assertEquals(expectedPath, type.getPath());
155 expectedQName = QName.create(GD_NS, GD_REV, "int-ext");
156 path.offer(expectedQName);
157 expectedPath = SchemaPath.create(true, expectedQName);
158 assertEquals(expectedPath, type.getType().getPath());
159 UnionTypeDefinition union = (UnionTypeDefinition) type.getType().getBaseType();
160 assertEquals(SchemaPath.create(true, expectedQName, QName.create(expectedQName, "union")), union.getPath());
161 assertEquals(2, union.getTypes().size());
162 // * |-- list requests
163 ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName("requests");
164 assertNotNull(requests);
165 expectedQName = QName.create(UG_NS, UG_REV, "requests");
166 assertEquals(expectedQName, requests.getQName());
169 path.offer(expectedQName);
170 expectedPath = SchemaPath.create(path, true);
171 assertEquals(expectedPath, requests.getPath());
172 assertFalse(requests.isAddedByUses());
173 childNodes = requests.getChildNodes();
174 assertEquals(3, childNodes.size());
175 // * |-- |-- container rp
176 ContainerSchemaNode rp = (ContainerSchemaNode) requests.getDataChildByName("rp");
178 expectedQName = QName.create(UG_NS, UG_REV, "rp");
179 path.offer(expectedQName);
180 expectedPath = SchemaPath.create(path, true);
181 assertEquals(expectedPath, rp.getPath());
182 assertFalse(rp.isAddedByUses());
183 childNodes = rp.getChildNodes();
184 assertEquals(4, childNodes.size());
185 // * |-- |-- |-- leaf processing-rule
186 LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName("processing-rule");
187 assertNotNull(processingRule);
188 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
189 assertEquals(expectedQName, processingRule.getQName());
190 path.offer(expectedQName);
191 expectedPath = SchemaPath.create(path, true);
192 assertEquals(expectedPath, processingRule.getPath());
193 assertEquals(BaseTypes.booleanType(), processingRule.getType());
194 assertTrue(processingRule.isAddedByUses());
195 // * |-- |-- |-- leaf ignore
196 LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName("ignore");
197 assertNotNull(ignore);
198 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
199 assertEquals(expectedQName, ignore.getQName());
201 path.offer(expectedQName);
202 expectedPath = SchemaPath.create(path, true);
203 assertEquals(expectedPath, ignore.getPath());
204 assertEquals(BaseTypes.booleanType(), ignore.getType());
205 assertTrue(ignore.isAddedByUses());
206 // * |-- |-- |-- leaf priority
207 LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName("priority");
208 assertNotNull(priority);
209 expectedQName = QName.create(UG_NS, UG_REV, "priority");
210 assertEquals(expectedQName, priority.getQName());
212 path.offer(expectedQName);
213 expectedPath = SchemaPath.create(path, true);
214 assertEquals(expectedPath, priority.getPath());
215 expectedQName = QName.create(UG_NS, UG_REV, "uint8");
216 path.offer(expectedQName);
217 expectedPath = SchemaPath.create(path, true);
219 //assertEquals(expectedPath, priority.getType().getPath());
220 assertEquals(BaseTypes.uint8Type(), priority.getType().getBaseType());
221 assertTrue(priority.isAddedByUses());
222 // * |-- |-- |-- container box
223 ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName("box");
225 expectedQName = QName.create(UG_NS, UG_REV, "box");
226 assertEquals(expectedQName, box.getQName());
229 path.offer(expectedQName);
230 expectedPath = SchemaPath.create(path, true);
231 assertEquals(expectedPath, box.getPath());
232 assertTrue(box.isAddedByUses());
233 // * |-- |-- |-- |-- container order
234 ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName("order");
235 assertNotNull(order);
236 expectedQName = QName.create(UG_NS, UG_REV, "order");
237 assertEquals(expectedQName, order.getQName());
238 path.offer(expectedQName);
239 expectedPath = SchemaPath.create(path, true);
240 assertEquals(expectedPath, order.getPath());
241 assertTrue(order.isAddedByUses());
242 assertTrue(order.isAugmenting());
243 assertEquals(2, order.getChildNodes().size());
244 // * |-- |-- |-- |-- |-- leaf delete
245 LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName("delete");
246 assertNotNull(delete);
247 expectedQName = QName.create(UG_NS, UG_REV, "delete");
248 assertEquals(expectedQName, delete.getQName());
249 path.offer(expectedQName);
250 expectedPath = SchemaPath.create(path, true);
251 assertEquals(expectedPath, delete.getPath());
252 assertEquals(BaseTypes.uint32Type(), delete.getType());
253 assertTrue(delete.isAddedByUses());
254 // * |-- |-- |-- |-- |-- leaf setup
255 LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName("setup");
256 assertNotNull(setup);
257 expectedQName = QName.create(UG_NS, UG_REV, "setup");
258 assertEquals(expectedQName, setup.getQName());
260 path.offer(expectedQName);
261 expectedPath = SchemaPath.create(path, true);
262 assertEquals(expectedPath, setup.getPath());
263 assertEquals(BaseTypes.uint32Type(), setup.getType());
264 assertTrue(setup.isAddedByUses());
265 // * |-- |-- path-key-expansion
266 ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName("path-key-expansion");
268 expectedQName = QName.create(UG_NS, UG_REV, "path-key-expansion");
269 assertEquals(expectedQName, pke.getQName());
274 path.offer(expectedQName);
275 expectedPath = SchemaPath.create(path, true);
276 assertEquals(expectedPath, pke.getPath());
277 assertFalse(pke.isAddedByUses());
278 // * |-- |-- |-- path-key
279 ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName("path-key");
280 assertNotNull(pathKey);
281 expectedQName = QName.create(UG_NS, UG_REV, "path-key");
282 assertEquals(expectedQName, pathKey.getQName());
283 path.offer(expectedQName);
284 expectedPath= SchemaPath.create(path, true);
285 assertEquals(expectedPath, pathKey.getPath());
286 assertFalse(pathKey.isAddedByUses());
287 assertEquals(3, pathKey.getChildNodes().size());
288 // * |-- |-- |-- |-- leaf processing-rule
289 processingRule = (LeafSchemaNode) pathKey.getDataChildByName("processing-rule");
290 assertNotNull(processingRule);
291 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
292 assertEquals(expectedQName, processingRule.getQName());
293 path.offer(expectedQName);
294 expectedPath= SchemaPath.create(path, true);
295 assertEquals(expectedPath, processingRule.getPath());
296 assertEquals(BaseTypes.booleanType(), processingRule.getType());
297 assertTrue(processingRule.isAddedByUses());
298 // * |-- |-- |-- |-- leaf ignore
299 ignore = (LeafSchemaNode) pathKey.getDataChildByName("ignore");
300 assertNotNull(ignore);
301 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
302 assertEquals(expectedQName, ignore.getQName());
304 path.offer(expectedQName);
305 expectedPath= SchemaPath.create(path, true);
306 assertEquals(expectedPath, ignore.getPath());
307 assertEquals(BaseTypes.booleanType(), ignore.getType());
308 assertTrue(ignore.isAddedByUses());
309 // * |-- |-- |-- |-- list path-keys
310 ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName("path-keys");
311 assertNotNull(pathKeys);
312 expectedQName = QName.create(UG_NS, UG_REV, "path-keys");
313 assertEquals(expectedQName, pathKeys.getQName());
315 path.offer(expectedQName);
316 expectedPath= SchemaPath.create(path, true);
317 assertEquals(expectedPath, pathKeys.getPath());
318 assertTrue(pathKeys.isAddedByUses());
319 childNodes = pathKeys.getChildNodes();
320 assertEquals(2, childNodes.size());
321 // * |-- |-- |-- |-- |-- leaf version
322 version = (LeafSchemaNode) pathKeys.getDataChildByName("version");
323 assertNotNull(version);
324 expectedQName = QName.create(UG_NS, UG_REV, "version");
325 assertEquals(expectedQName, version.getQName());
326 path.offer(expectedQName);
327 expectedPath= SchemaPath.create(path, true);
328 assertEquals(expectedPath, version.getPath());
329 assertTrue(version.getType() instanceof UnsignedIntegerTypeDefinition);
330 assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
331 assertTrue(version.isAddedByUses());
332 assertTrue(version.isAugmenting());
333 // * |-- |-- |-- |-- |-- leaf type
334 type = (LeafSchemaNode) pathKeys.getDataChildByName("type");
336 expectedQName = QName.create(UG_NS, UG_REV, "type");
337 assertEquals(expectedQName, type.getQName());
339 path.offer(expectedQName);
340 expectedPath= SchemaPath.create(path, true);
341 assertEquals(expectedPath, type.getPath());
342 assertTrue(type.getType() instanceof UnionTypeDefinition);
343 assertTrue(type.isAddedByUses());
344 assertTrue(type.isAugmenting());
345 // * |-- |-- container segment-computation
346 ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName("segment-computation");
348 expectedQName = QName.create(UG_NS, UG_REV, "segment-computation");
349 assertEquals(expectedQName, sc.getQName());
354 path.offer(expectedQName);
355 expectedPath= SchemaPath.create(path, true);
356 assertEquals(expectedPath, sc.getPath());
357 assertFalse(sc.isAddedByUses());
358 // * |-- |-- |-- container p2p
359 ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName("p2p");
361 expectedQName = QName.create(UG_NS, UG_REV, "p2p");
362 assertEquals(expectedQName, p2p.getQName());
363 path.offer(expectedQName);
364 expectedPath= SchemaPath.create(path, true);
365 assertEquals(expectedPath, p2p.getPath());
366 assertFalse(p2p.isAddedByUses());
367 // * |-- |-- |-- |-- container endpoints
368 ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName("endpoints");
369 assertNotNull(endpoints);
370 expectedQName = QName.create(UG_NS, UG_REV, "endpoints");
371 assertEquals(expectedQName, endpoints.getQName());
372 path.offer(expectedQName);
373 expectedPath= SchemaPath.create(path, true);
374 assertEquals(expectedPath, endpoints.getPath());
375 assertFalse(endpoints.isAddedByUses());
376 // * |-- |-- |-- |-- |-- leaf processing-rule
377 processingRule = (LeafSchemaNode) endpoints.getDataChildByName("processing-rule");
378 assertNotNull(processingRule);
379 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
380 assertEquals(expectedQName, processingRule.getQName());
381 path.offer(expectedQName);
382 expectedPath= SchemaPath.create(path, true);
383 assertEquals(expectedPath, processingRule.getPath());
384 assertEquals(BaseTypes.booleanType(), processingRule.getType());
385 assertTrue(processingRule.isAddedByUses());
386 // * |-- |-- |-- |-- |-- leaf ignore
387 ignore = (LeafSchemaNode) endpoints.getDataChildByName("ignore");
388 assertNotNull(ignore);
389 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
390 assertEquals(expectedQName, ignore.getQName());
392 path.offer(expectedQName);
393 expectedPath= SchemaPath.create(path, true);
394 assertEquals(expectedPath, ignore.getPath());
395 assertEquals(BaseTypes.booleanType(), ignore.getType());
396 assertTrue(ignore.isAddedByUses());
397 // * |-- |-- |-- |-- |-- container box
398 box = (ContainerSchemaNode) endpoints.getDataChildByName("box");
400 expectedQName = QName.create(UG_NS, UG_REV, "box");
401 assertEquals(expectedQName, box.getQName());
403 path.offer(expectedQName);
404 expectedPath= SchemaPath.create(path, true);
405 assertEquals(expectedPath, box.getPath());
406 assertTrue(box.isAddedByUses());
407 // * |-- |-- |-- |-- |-- choice address-family
408 ChoiceSchemaNode af = (ChoiceSchemaNode) endpoints.getDataChildByName("address-family");
410 expectedQName = QName.create(UG_NS, UG_REV, "address-family");
411 assertEquals(expectedQName, af.getQName());
413 path.offer(expectedQName);
414 expectedPath= SchemaPath.create(path, true);
415 assertEquals(expectedPath, af.getPath());
416 assertTrue(af.isAddedByUses());
417 // * |-- |-- |-- |-- container reported-route
418 ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName("reported-route");
419 assertNotNull(reportedRoute);
420 expectedQName = QName.create(UG_NS, UG_REV, "reported-route");
421 assertEquals(expectedQName, reportedRoute.getQName());
424 path.offer(expectedQName);
425 expectedPath= SchemaPath.create(path, true);
426 assertEquals(expectedPath, reportedRoute.getPath());
427 assertFalse(reportedRoute.isAddedByUses());
428 // * |-- |-- |-- |-- |-- leaf processing-rule
429 processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName("processing-rule");
430 assertNotNull(processingRule);
431 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
432 assertEquals(expectedQName, processingRule.getQName());
433 path.offer(expectedQName);
434 expectedPath= SchemaPath.create(path, true);
435 assertEquals(expectedPath, processingRule.getPath());
436 assertEquals(BaseTypes.booleanType(), processingRule.getType());
437 assertTrue(processingRule.isAddedByUses());
438 // * |-- |-- |-- |-- |-- leaf ignore
439 ignore = (LeafSchemaNode) reportedRoute.getDataChildByName("ignore");
440 assertNotNull(ignore);
441 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
442 assertEquals(expectedQName, ignore.getQName());
444 path.offer(expectedQName);
445 expectedPath= SchemaPath.create(path, true);
446 assertEquals(expectedPath, ignore.getPath());
447 assertEquals(BaseTypes.booleanType(), ignore.getType());
448 assertTrue(ignore.isAddedByUses());
449 // * |-- |-- |-- |-- |-- list subobjects
450 ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName("subobjects");
451 assertNotNull(subobjects);
452 expectedQName = QName.create(UG_NS, UG_REV, "subobjects");
453 assertEquals(expectedQName, subobjects.getQName());
455 path.offer(expectedQName);
456 expectedPath= SchemaPath.create(path, true);
457 assertEquals(expectedPath, subobjects.getPath());
458 assertTrue(subobjects.isAddedByUses());
459 // * |-- |-- |-- |-- |-- container bandwidth
460 ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName("bandwidth");
461 assertNotNull(bandwidth);
462 expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
463 assertEquals(expectedQName, bandwidth.getQName());
465 path.offer(expectedQName);
466 expectedPath= SchemaPath.create(path, true);
467 assertEquals(expectedPath, bandwidth.getPath());
468 assertFalse(bandwidth.isAddedByUses());
469 // * |-- |-- |-- |-- container bandwidth
470 bandwidth = (ContainerSchemaNode) p2p.getDataChildByName("bandwidth");
471 assertNotNull(bandwidth);
472 expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
473 assertEquals(expectedQName, bandwidth.getQName());
476 path.offer(expectedQName);
477 expectedPath= SchemaPath.create(path, true);
478 assertEquals(expectedPath, bandwidth.getPath());
479 assertTrue(bandwidth.isAddedByUses());
480 // * |-- |-- |-- |-- |-- leaf processing-rule
481 processingRule = (LeafSchemaNode) bandwidth.getDataChildByName("processing-rule");
482 assertNotNull(processingRule);
483 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
484 assertEquals(expectedQName, processingRule.getQName());
485 path.offer(expectedQName);
486 expectedPath= SchemaPath.create(path, true);
487 assertEquals(expectedPath, processingRule.getPath());
488 assertEquals(BaseTypes.booleanType(), processingRule.getType());
489 assertTrue(processingRule.isAddedByUses());
490 // * |-- |-- |-- |-- |-- leaf ignore
491 ignore = (LeafSchemaNode) bandwidth.getDataChildByName("ignore");
492 assertNotNull(ignore);
493 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
494 assertEquals(expectedQName, ignore.getQName());
496 path.offer(expectedQName);
497 expectedPath= SchemaPath.create(path, true);
498 assertEquals(expectedPath, ignore.getPath());
499 assertEquals(BaseTypes.booleanType(), ignore.getType());
500 assertTrue(ignore.isAddedByUses());
501 // * |-- |-- |-- |-- |-- container bandwidth
502 ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName("bandwidth");
503 assertNotNull(bandwidthInner);
504 expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
505 assertEquals(expectedQName, bandwidth.getQName());
507 path.offer(expectedQName);
508 expectedPath= SchemaPath.create(path, true);
509 assertEquals(expectedPath, bandwidthInner.getPath());
510 assertTrue(bandwidthInner.isAddedByUses());
512 ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName("svec");
514 expectedQName = QName.create(UG_NS, UG_REV, "svec");
515 assertEquals(expectedQName, svec.getQName());
521 path.offer(expectedQName);
522 expectedPath= SchemaPath.create(path, true);
523 assertEquals(expectedPath, svec.getPath());
524 assertFalse(svec.isAddedByUses());
525 // * |-- |-- leaf link-diverse
526 LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName("link-diverse");
527 assertNotNull(linkDiverse);
528 expectedQName = QName.create(UG_NS, UG_REV, "link-diverse");
529 assertEquals(expectedQName, linkDiverse.getQName());
530 path.offer(expectedQName);
531 expectedPath= SchemaPath.create(path, true);
532 assertEquals(expectedPath, linkDiverse.getPath());
533 assertEquals(BaseTypes.booleanType(), linkDiverse.getType().getBaseType());
534 assertTrue(linkDiverse.isAddedByUses());
535 // * |-- |-- leaf processing-rule
536 processingRule = (LeafSchemaNode) svec.getDataChildByName("processing-rule");
537 assertNotNull(processingRule);
538 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
539 assertEquals(expectedQName, processingRule.getQName());
541 path.offer(expectedQName);
542 expectedPath= SchemaPath.create(path, true);
543 assertEquals(expectedPath, processingRule.getPath());
544 assertEquals(BaseTypes.booleanType(), processingRule.getType());
545 assertTrue(processingRule.isAddedByUses());
546 // * |-- |-- leaf ignore
547 ignore = (LeafSchemaNode) svec.getDataChildByName("ignore");
548 assertNotNull(ignore);
549 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
550 assertEquals(expectedQName, ignore.getQName());
552 path.offer(expectedQName);
553 expectedPath= SchemaPath.create(path, true);
554 assertEquals(expectedPath, ignore.getPath());
555 assertEquals(BaseTypes.booleanType(), ignore.getType());
556 assertTrue(ignore.isAddedByUses());
557 // * |-- |-- list metric
558 ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName("metric");
559 assertNotNull(metric);
560 expectedQName = QName.create(UG_NS, UG_REV, "metric");
561 assertEquals(expectedQName, metric.getQName());
563 path.offer(expectedQName);
564 expectedPath= SchemaPath.create(path, true);
565 assertEquals(expectedPath, metric.getPath());
566 assertFalse(metric.isAddedByUses());
567 // * |-- |-- |-- leaf metric-type
568 LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName("metric-type");
569 assertNotNull(metricType);
570 expectedQName = QName.create(UG_NS, UG_REV, "metric-type");
571 assertEquals(expectedQName, metricType.getQName());
572 path.offer(expectedQName);
573 expectedPath= SchemaPath.create(path, true);
574 assertEquals(expectedPath, metricType.getPath());
575 assertEquals(BaseTypes.uint8Type(), metricType.getType());
576 assertTrue(metricType.isAddedByUses());
578 box = (ContainerSchemaNode) metric.getDataChildByName("box");
580 expectedQName = QName.create(UG_NS, UG_REV, "box");
581 assertEquals(expectedQName, box.getQName());
583 path.offer(expectedQName);
584 expectedPath= SchemaPath.create(path, true);
585 assertEquals(expectedPath, box.getPath());
586 assertTrue(box.isAddedByUses());
587 // * |-- |-- |-- leaf processing-rule
588 processingRule = (LeafSchemaNode) metric.getDataChildByName("processing-rule");
589 assertNotNull(processingRule);
590 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
591 assertEquals(expectedQName, processingRule.getQName());
593 path.offer(expectedQName);
594 expectedPath= SchemaPath.create(path, true);
595 assertEquals(expectedPath, processingRule.getPath());
596 assertEquals(BaseTypes.booleanType(), processingRule.getType());
597 assertTrue(processingRule.isAddedByUses());
598 // * |-- |-- |-- leaf ignore
599 ignore = (LeafSchemaNode) metric.getDataChildByName("ignore");
600 assertNotNull(ignore);
601 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
602 assertEquals(expectedQName, ignore.getQName());
604 path.offer(expectedQName);
605 expectedPath= SchemaPath.create(path, true);
606 assertEquals(expectedPath, ignore.getPath());
607 assertEquals(BaseTypes.booleanType(), ignore.getType());
608 assertTrue(ignore.isAddedByUses());
612 public void testTypedefs() throws URISyntaxException, SourceException, ReactorException {
613 modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
614 Module testModule = TestUtils.findModule(modules, "grouping-definitions");
615 Set<TypeDefinition<?>> types = testModule.getTypeDefinitions();
617 TypeDefinition<?> intExt = null;
618 for(TypeDefinition<?> td : types) {
619 if("int-ext".equals(td.getQName().getLocalName())) {
623 assertNotNull(intExt);
625 SchemaPath expectedPath = SchemaPath.create(true, QName.create(GD_NS, GD_REV, "int-ext"));
626 assertEquals(expectedPath, intExt.getPath());
628 UnionTypeDefinition union = (UnionTypeDefinition)intExt.getBaseType();
630 TypeDefinition<?> uint8 = null;
631 TypeDefinition<?> pv = null;
632 for(TypeDefinition<?> td : union.getTypes()) {
633 if("uint8".equals(td.getQName().getLocalName())) {
635 } else if("protocol-version".equals(td.getQName().getLocalName())) {
639 assertNotNull(uint8);
642 expectedPath = SchemaPath.create(true, QName.create(GD_NS, GD_REV, "int-ext"), QName.create(GD_NS, GD_REV, "union"));
643 assertEquals(expectedPath, union.getPath());