2 * Copyright (c) 2013 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.retest;
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 com.google.common.collect.Lists;
15 import java.io.FileNotFoundException;
17 import java.net.URISyntaxException;
18 import java.text.DateFormat;
19 import java.text.ParseException;
20 import java.text.SimpleDateFormat;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.LinkedList;
24 import java.util.List;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.opendaylight.yangtools.yang.common.QName;
29 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
30 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
31 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
32 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
33 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
34 import org.opendaylight.yangtools.yang.model.api.Module;
35 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
36 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
37 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
38 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
39 import org.opendaylight.yangtools.yang.model.util.BooleanType;
40 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
41 import org.opendaylight.yangtools.yang.model.util.Uint32;
42 import org.opendaylight.yangtools.yang.model.util.Uint8;
43 import org.opendaylight.yangtools.yang.model.util.UnionType;
44 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
45 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
47 public class UsesAugmentTest {
48 private static final URI UG_NS = URI.create("urn:opendaylight:params:xml:ns:yang:uses-grouping");
49 private static final URI GD_NS = URI.create("urn:opendaylight:params:xml:ns:yang:grouping-definitions");
53 private Set<Module> modules;
56 public void init() throws FileNotFoundException, ParseException {
57 DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
58 UG_REV = simpleDateFormat.parse("2013-07-30");
59 GD_REV = simpleDateFormat.parse("2013-09-04");
63 * Structure of testing model:
66 * |-- leaf version (U)
69 * |-- |-- container rp
70 * |-- |-- |-- leaf priority (U)
71 * |-- |-- |-- container box (U)
72 * |-- |-- |-- |-- container order (A)
73 * |-- |-- |-- |-- |-- leaf delete (U)
74 * |-- |-- |-- |-- |-- |-- leaf setup (U)
75 * |-- |-- |-- leaf processing-rule (U)
76 * |-- |-- |-- leaf ignore (U)
77 * |-- |-- path-key-expansion
78 * |-- |-- |-- container path-key
79 * |-- |-- |-- |-- list path-keys (U)
80 * |-- |-- |-- |-- |-- leaf version (U)
81 * |-- |-- |-- |-- |-- leaf type (U)
82 * |-- |-- |-- |-- |-- leaf processing-rule (U)
83 * |-- |-- |-- |-- |-- leaf ignore (U)
84 * |-- |-- container segment-computation
85 * |-- |-- |-- container p2p
86 * |-- |-- |-- |-- container endpoints
87 * |-- |-- |-- |-- |-- leaf processing-rule (U)
88 * |-- |-- |-- |-- |-- leaf ignore (U)
89 * |-- |-- |-- |-- |-- container box (U)
90 * |-- |-- |-- |-- |-- choice address-family (U)
91 * |-- |-- |-- |-- |-- |-- case ipv4
92 * |-- |-- |-- |-- |-- |-- |-- leaf source-ipv4-address
93 * |-- |-- |-- |-- |-- |-- case ipv6
94 * |-- |-- |-- |-- |-- |-- |-- leaf source-ipv6-address
95 * |-- |-- |-- |-- container reported-route
96 * |-- |-- |-- |-- |-- container bandwidth
97 * |-- |-- |-- |-- |-- list subobjects(U)
98 * |-- |-- |-- |-- |-- leaf processing-rule (U)
99 * |-- |-- |-- |-- |-- leaf ignore (U)
100 * |-- |-- |-- |-- container bandwidth (U)
101 * |-- |-- |-- |-- |-- container bandwidth (U)
102 * |-- |-- |-- |-- |-- leaf processing-rule (U)
103 * |-- |-- |-- |-- |-- leaf ignore (U)
105 * |-- |-- list metric
106 * |-- |-- |-- leaf metric-type (U)
107 * |-- |-- |-- container box (U)
108 * |-- |-- |-- leaf processing-rule (U)
109 * |-- |-- |-- leaf ignore (U)
110 * |-- |-- leaf link-diverse (U)
111 * |-- |-- leaf processing-rule (U)
112 * |-- |-- leaf ignore (U)
114 * U = added by uses A = added by augment
117 public void testAugmentInUses() throws Exception {
118 modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
119 Module testModule = TestUtils.findModule(modules, "uses-grouping");
121 LinkedList<QName> path = new LinkedList<>();
123 // * notification pcreq
124 Set<NotificationDefinition> notifications = testModule.getNotifications();
125 assertEquals(1, notifications.size());
126 NotificationDefinition pcreq = notifications.iterator().next();
127 assertNotNull(pcreq);
128 QName expectedQName = QName.create(UG_NS, UG_REV, "pcreq");
129 path.offer(expectedQName);
130 SchemaPath expectedPath = SchemaPath.create(path, true);
131 assertEquals(expectedPath, pcreq.getPath());
132 Collection<DataSchemaNode> childNodes = pcreq.getChildNodes();
133 assertEquals(4, childNodes.size());
134 // * |-- leaf version
135 LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName("version");
136 assertNotNull(version);
137 expectedQName = QName.create(UG_NS, UG_REV, "version");
138 path.offer(expectedQName);
139 expectedPath = SchemaPath.create(path, true);
140 assertEquals(expectedPath, version.getPath());
141 expectedQName = QName.create(GD_NS, GD_REV, "protocol-version");
142 path.offer(expectedQName);
143 expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
144 assertEquals(expectedPath, version.getType().getPath());
145 assertEquals(Uint8.getInstance(), version.getType().getBaseType());
146 assertTrue(version.isAddedByUses());
148 LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName("type");
150 expectedQName = QName.create(UG_NS, UG_REV, "type");
151 assertTrue(type.isAddedByUses());
154 path.offer(expectedQName);
155 expectedPath = SchemaPath.create(path, true);
156 assertEquals(expectedPath, type.getPath());
157 expectedQName = QName.create(GD_NS, GD_REV, "int-ext");
158 path.offer(expectedQName);
159 expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
160 assertEquals(expectedPath, type.getType().getPath());
161 UnionType union = (UnionType)type.getType().getBaseType();
162 assertEquals(SchemaPath.create(true, BaseTypes.constructQName("union")), union.getPath());
163 assertEquals(2, union.getTypes().size());
164 // * |-- list requests
165 ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName("requests");
166 assertNotNull(requests);
167 expectedQName = QName.create(UG_NS, UG_REV, "requests");
168 assertEquals(expectedQName, requests.getQName());
171 path.offer(expectedQName);
172 expectedPath = SchemaPath.create(path, true);
173 assertEquals(expectedPath, requests.getPath());
174 assertFalse(requests.isAddedByUses());
175 childNodes = requests.getChildNodes();
176 assertEquals(3, childNodes.size());
177 // * |-- |-- container rp
178 ContainerSchemaNode rp = (ContainerSchemaNode) requests.getDataChildByName("rp");
180 expectedQName = QName.create(UG_NS, UG_REV, "rp");
181 path.offer(expectedQName);
182 expectedPath = SchemaPath.create(path, true);
183 assertEquals(expectedPath, rp.getPath());
184 assertFalse(rp.isAddedByUses());
185 childNodes = rp.getChildNodes();
186 assertEquals(4, childNodes.size());
187 // * |-- |-- |-- leaf processing-rule
188 LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName("processing-rule");
189 assertNotNull(processingRule);
190 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
191 assertEquals(expectedQName, processingRule.getQName());
192 path.offer(expectedQName);
193 expectedPath = SchemaPath.create(path, true);
194 assertEquals(expectedPath, processingRule.getPath());
195 assertEquals(BooleanType.getInstance(), processingRule.getType());
196 assertTrue(processingRule.isAddedByUses());
197 // * |-- |-- |-- leaf ignore
198 LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName("ignore");
199 assertNotNull(ignore);
200 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
201 assertEquals(expectedQName, ignore.getQName());
203 path.offer(expectedQName);
204 expectedPath = SchemaPath.create(path, true);
205 assertEquals(expectedPath, ignore.getPath());
206 assertEquals(BooleanType.getInstance(), ignore.getType());
207 assertTrue(ignore.isAddedByUses());
208 // * |-- |-- |-- leaf priority
209 LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName("priority");
210 assertNotNull(priority);
211 expectedQName = QName.create(UG_NS, UG_REV, "priority");
212 assertEquals(expectedQName, priority.getQName());
214 path.offer(expectedQName);
215 expectedPath = SchemaPath.create(path, true);
216 assertEquals(expectedPath, priority.getPath());
217 expectedQName = QName.create(UG_NS, UG_REV, "uint8");
218 path.offer(expectedQName);
219 expectedPath = SchemaPath.create(path, true);
221 //assertEquals(expectedPath, priority.getType().getPath());
222 assertEquals(Uint8.getInstance(), priority.getType().getBaseType());
223 assertTrue(priority.isAddedByUses());
224 // * |-- |-- |-- container box
225 ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName("box");
227 expectedQName = QName.create(UG_NS, UG_REV, "box");
228 assertEquals(expectedQName, box.getQName());
231 path.offer(expectedQName);
232 expectedPath = SchemaPath.create(path, true);
233 assertEquals(expectedPath, box.getPath());
234 assertTrue(box.isAddedByUses());
235 // * |-- |-- |-- |-- container order
236 ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName("order");
237 assertNotNull(order);
238 expectedQName = QName.create(UG_NS, UG_REV, "order");
239 assertEquals(expectedQName, order.getQName());
240 path.offer(expectedQName);
241 expectedPath = SchemaPath.create(path, true);
242 assertEquals(expectedPath, order.getPath());
243 assertTrue(order.isAddedByUses());
244 assertTrue(order.isAugmenting());
245 assertEquals(2, order.getChildNodes().size());
246 // * |-- |-- |-- |-- |-- leaf delete
247 LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName("delete");
248 assertNotNull(delete);
249 expectedQName = QName.create(UG_NS, UG_REV, "delete");
250 assertEquals(expectedQName, delete.getQName());
251 path.offer(expectedQName);
252 expectedPath = SchemaPath.create(path, true);
253 assertEquals(expectedPath, delete.getPath());
254 assertEquals(Uint32.getInstance(), delete.getType());
255 assertTrue(delete.isAddedByUses());
256 // * |-- |-- |-- |-- |-- leaf setup
257 LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName("setup");
258 assertNotNull(setup);
259 expectedQName = QName.create(UG_NS, UG_REV, "setup");
260 assertEquals(expectedQName, setup.getQName());
262 path.offer(expectedQName);
263 expectedPath = SchemaPath.create(path, true);
264 assertEquals(expectedPath, setup.getPath());
265 assertEquals(Uint32.getInstance(), setup.getType());
266 assertTrue(setup.isAddedByUses());
267 // * |-- |-- path-key-expansion
268 ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName("path-key-expansion");
270 expectedQName = QName.create(UG_NS, UG_REV, "path-key-expansion");
271 assertEquals(expectedQName, pke.getQName());
276 path.offer(expectedQName);
277 expectedPath = SchemaPath.create(path, true);
278 assertEquals(expectedPath, pke.getPath());
279 assertFalse(pke.isAddedByUses());
280 // * |-- |-- |-- path-key
281 ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName("path-key");
282 assertNotNull(pathKey);
283 expectedQName = QName.create(UG_NS, UG_REV, "path-key");
284 assertEquals(expectedQName, pathKey.getQName());
285 path.offer(expectedQName);
286 expectedPath= SchemaPath.create(path, true);
287 assertEquals(expectedPath, pathKey.getPath());
288 assertFalse(pathKey.isAddedByUses());
289 assertEquals(3, pathKey.getChildNodes().size());
290 // * |-- |-- |-- |-- leaf processing-rule
291 processingRule = (LeafSchemaNode) pathKey.getDataChildByName("processing-rule");
292 assertNotNull(processingRule);
293 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
294 assertEquals(expectedQName, processingRule.getQName());
295 path.offer(expectedQName);
296 expectedPath= SchemaPath.create(path, true);
297 assertEquals(expectedPath, processingRule.getPath());
298 assertEquals(BooleanType.getInstance(), processingRule.getType());
299 assertTrue(processingRule.isAddedByUses());
300 // * |-- |-- |-- |-- leaf ignore
301 ignore = (LeafSchemaNode) pathKey.getDataChildByName("ignore");
302 assertNotNull(ignore);
303 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
304 assertEquals(expectedQName, ignore.getQName());
306 path.offer(expectedQName);
307 expectedPath= SchemaPath.create(path, true);
308 assertEquals(expectedPath, ignore.getPath());
309 assertEquals(BooleanType.getInstance(), ignore.getType());
310 assertTrue(ignore.isAddedByUses());
311 // * |-- |-- |-- |-- list path-keys
312 ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName("path-keys");
313 assertNotNull(pathKeys);
314 expectedQName = QName.create(UG_NS, UG_REV, "path-keys");
315 assertEquals(expectedQName, pathKeys.getQName());
317 path.offer(expectedQName);
318 expectedPath= SchemaPath.create(path, true);
319 assertEquals(expectedPath, pathKeys.getPath());
320 assertTrue(pathKeys.isAddedByUses());
321 childNodes = pathKeys.getChildNodes();
322 assertEquals(2, childNodes.size());
323 // * |-- |-- |-- |-- |-- leaf version
324 version = (LeafSchemaNode) pathKeys.getDataChildByName("version");
325 assertNotNull(version);
326 expectedQName = QName.create(UG_NS, UG_REV, "version");
327 assertEquals(expectedQName, version.getQName());
328 path.offer(expectedQName);
329 expectedPath= SchemaPath.create(path, true);
330 assertEquals(expectedPath, version.getPath());
331 assertTrue(version.getType() instanceof ExtendedType);
332 assertEquals(Uint8.getInstance(), version.getType().getBaseType());
333 assertTrue(version.isAddedByUses());
334 assertTrue(version.isAugmenting());
335 // * |-- |-- |-- |-- |-- leaf type
336 type = (LeafSchemaNode) pathKeys.getDataChildByName("type");
338 expectedQName = QName.create(UG_NS, UG_REV, "type");
339 assertEquals(expectedQName, type.getQName());
341 path.offer(expectedQName);
342 expectedPath= SchemaPath.create(path, true);
343 assertEquals(expectedPath, type.getPath());
344 assertTrue(type.getType() instanceof ExtendedType);
345 assertTrue(type.isAddedByUses());
346 assertTrue(type.isAugmenting());
347 // * |-- |-- container segment-computation
348 ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName("segment-computation");
350 expectedQName = QName.create(UG_NS, UG_REV, "segment-computation");
351 assertEquals(expectedQName, sc.getQName());
356 path.offer(expectedQName);
357 expectedPath= SchemaPath.create(path, true);
358 assertEquals(expectedPath, sc.getPath());
359 assertFalse(sc.isAddedByUses());
360 // * |-- |-- |-- container p2p
361 ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName("p2p");
363 expectedQName = QName.create(UG_NS, UG_REV, "p2p");
364 assertEquals(expectedQName, p2p.getQName());
365 path.offer(expectedQName);
366 expectedPath= SchemaPath.create(path, true);
367 assertEquals(expectedPath, p2p.getPath());
368 assertFalse(p2p.isAddedByUses());
369 // * |-- |-- |-- |-- container endpoints
370 ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName("endpoints");
371 assertNotNull(endpoints);
372 expectedQName = QName.create(UG_NS, UG_REV, "endpoints");
373 assertEquals(expectedQName, endpoints.getQName());
374 path.offer(expectedQName);
375 expectedPath= SchemaPath.create(path, true);
376 assertEquals(expectedPath, endpoints.getPath());
377 assertFalse(endpoints.isAddedByUses());
378 // * |-- |-- |-- |-- |-- leaf processing-rule
379 processingRule = (LeafSchemaNode) endpoints.getDataChildByName("processing-rule");
380 assertNotNull(processingRule);
381 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
382 assertEquals(expectedQName, processingRule.getQName());
383 path.offer(expectedQName);
384 expectedPath= SchemaPath.create(path, true);
385 assertEquals(expectedPath, processingRule.getPath());
386 assertEquals(BooleanType.getInstance(), processingRule.getType());
387 assertTrue(processingRule.isAddedByUses());
388 // * |-- |-- |-- |-- |-- leaf ignore
389 ignore = (LeafSchemaNode) endpoints.getDataChildByName("ignore");
390 assertNotNull(ignore);
391 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
392 assertEquals(expectedQName, ignore.getQName());
394 path.offer(expectedQName);
395 expectedPath= SchemaPath.create(path, true);
396 assertEquals(expectedPath, ignore.getPath());
397 assertEquals(BooleanType.getInstance(), ignore.getType());
398 assertTrue(ignore.isAddedByUses());
399 // * |-- |-- |-- |-- |-- container box
400 box = (ContainerSchemaNode) endpoints.getDataChildByName("box");
402 expectedQName = QName.create(UG_NS, UG_REV, "box");
403 assertEquals(expectedQName, box.getQName());
405 path.offer(expectedQName);
406 expectedPath= SchemaPath.create(path, true);
407 assertEquals(expectedPath, box.getPath());
408 assertTrue(box.isAddedByUses());
409 // * |-- |-- |-- |-- |-- choice address-family
410 ChoiceSchemaNode af = (ChoiceSchemaNode) endpoints.getDataChildByName("address-family");
412 expectedQName = QName.create(UG_NS, UG_REV, "address-family");
413 assertEquals(expectedQName, af.getQName());
415 path.offer(expectedQName);
416 expectedPath= SchemaPath.create(path, true);
417 assertEquals(expectedPath, af.getPath());
418 assertTrue(af.isAddedByUses());
419 // * |-- |-- |-- |-- container reported-route
420 ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName("reported-route");
421 assertNotNull(reportedRoute);
422 expectedQName = QName.create(UG_NS, UG_REV, "reported-route");
423 assertEquals(expectedQName, reportedRoute.getQName());
426 path.offer(expectedQName);
427 expectedPath= SchemaPath.create(path, true);
428 assertEquals(expectedPath, reportedRoute.getPath());
429 assertFalse(reportedRoute.isAddedByUses());
430 // * |-- |-- |-- |-- |-- leaf processing-rule
431 processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName("processing-rule");
432 assertNotNull(processingRule);
433 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
434 assertEquals(expectedQName, processingRule.getQName());
435 path.offer(expectedQName);
436 expectedPath= SchemaPath.create(path, true);
437 assertEquals(expectedPath, processingRule.getPath());
438 assertEquals(BooleanType.getInstance(), processingRule.getType());
439 assertTrue(processingRule.isAddedByUses());
440 // * |-- |-- |-- |-- |-- leaf ignore
441 ignore = (LeafSchemaNode) reportedRoute.getDataChildByName("ignore");
442 assertNotNull(ignore);
443 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
444 assertEquals(expectedQName, ignore.getQName());
446 path.offer(expectedQName);
447 expectedPath= SchemaPath.create(path, true);
448 assertEquals(expectedPath, ignore.getPath());
449 assertEquals(BooleanType.getInstance(), ignore.getType());
450 assertTrue(ignore.isAddedByUses());
451 // * |-- |-- |-- |-- |-- list subobjects
452 ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName("subobjects");
453 assertNotNull(subobjects);
454 expectedQName = QName.create(UG_NS, UG_REV, "subobjects");
455 assertEquals(expectedQName, subobjects.getQName());
457 path.offer(expectedQName);
458 expectedPath= SchemaPath.create(path, true);
459 assertEquals(expectedPath, subobjects.getPath());
460 assertTrue(subobjects.isAddedByUses());
461 // * |-- |-- |-- |-- |-- container bandwidth
462 ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName("bandwidth");
463 assertNotNull(bandwidth);
464 expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
465 assertEquals(expectedQName, bandwidth.getQName());
467 path.offer(expectedQName);
468 expectedPath= SchemaPath.create(path, true);
469 assertEquals(expectedPath, bandwidth.getPath());
470 assertFalse(bandwidth.isAddedByUses());
471 // * |-- |-- |-- |-- container bandwidth
472 bandwidth = (ContainerSchemaNode) p2p.getDataChildByName("bandwidth");
473 assertNotNull(bandwidth);
474 expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
475 assertEquals(expectedQName, bandwidth.getQName());
478 path.offer(expectedQName);
479 expectedPath= SchemaPath.create(path, true);
480 assertEquals(expectedPath, bandwidth.getPath());
481 assertTrue(bandwidth.isAddedByUses());
482 // * |-- |-- |-- |-- |-- leaf processing-rule
483 processingRule = (LeafSchemaNode) bandwidth.getDataChildByName("processing-rule");
484 assertNotNull(processingRule);
485 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
486 assertEquals(expectedQName, processingRule.getQName());
487 path.offer(expectedQName);
488 expectedPath= SchemaPath.create(path, true);
489 assertEquals(expectedPath, processingRule.getPath());
490 assertEquals(BooleanType.getInstance(), processingRule.getType());
491 assertTrue(processingRule.isAddedByUses());
492 // * |-- |-- |-- |-- |-- leaf ignore
493 ignore = (LeafSchemaNode) bandwidth.getDataChildByName("ignore");
494 assertNotNull(ignore);
495 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
496 assertEquals(expectedQName, ignore.getQName());
498 path.offer(expectedQName);
499 expectedPath= SchemaPath.create(path, true);
500 assertEquals(expectedPath, ignore.getPath());
501 assertEquals(BooleanType.getInstance(), ignore.getType());
502 assertTrue(ignore.isAddedByUses());
503 // * |-- |-- |-- |-- |-- container bandwidth
504 ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName("bandwidth");
505 assertNotNull(bandwidthInner);
506 expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
507 assertEquals(expectedQName, bandwidth.getQName());
509 path.offer(expectedQName);
510 expectedPath= SchemaPath.create(path, true);
511 assertEquals(expectedPath, bandwidthInner.getPath());
512 assertTrue(bandwidthInner.isAddedByUses());
514 ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName("svec");
516 expectedQName = QName.create(UG_NS, UG_REV, "svec");
517 assertEquals(expectedQName, svec.getQName());
523 path.offer(expectedQName);
524 expectedPath= SchemaPath.create(path, true);
525 assertEquals(expectedPath, svec.getPath());
526 assertFalse(svec.isAddedByUses());
527 // * |-- |-- leaf link-diverse
528 LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName("link-diverse");
529 assertNotNull(linkDiverse);
530 expectedQName = QName.create(UG_NS, UG_REV, "link-diverse");
531 assertEquals(expectedQName, linkDiverse.getQName());
532 path.offer(expectedQName);
533 expectedPath= SchemaPath.create(path, true);
534 assertEquals(expectedPath, linkDiverse.getPath());
535 assertEquals(BooleanType.getInstance(), linkDiverse.getType());
536 assertTrue(linkDiverse.isAddedByUses());
537 // * |-- |-- leaf processing-rule
538 processingRule = (LeafSchemaNode) svec.getDataChildByName("processing-rule");
539 assertNotNull(processingRule);
540 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
541 assertEquals(expectedQName, processingRule.getQName());
543 path.offer(expectedQName);
544 expectedPath= SchemaPath.create(path, true);
545 assertEquals(expectedPath, processingRule.getPath());
546 assertEquals(BooleanType.getInstance(), processingRule.getType());
547 assertTrue(processingRule.isAddedByUses());
548 // * |-- |-- leaf ignore
549 ignore = (LeafSchemaNode) svec.getDataChildByName("ignore");
550 assertNotNull(ignore);
551 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
552 assertEquals(expectedQName, ignore.getQName());
554 path.offer(expectedQName);
555 expectedPath= SchemaPath.create(path, true);
556 assertEquals(expectedPath, ignore.getPath());
557 assertEquals(BooleanType.getInstance(), ignore.getType());
558 assertTrue(ignore.isAddedByUses());
559 // * |-- |-- list metric
560 ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName("metric");
561 assertNotNull(metric);
562 expectedQName = QName.create(UG_NS, UG_REV, "metric");
563 assertEquals(expectedQName, metric.getQName());
565 path.offer(expectedQName);
566 expectedPath= SchemaPath.create(path, true);
567 assertEquals(expectedPath, metric.getPath());
568 assertFalse(metric.isAddedByUses());
569 // * |-- |-- |-- leaf metric-type
570 LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName("metric-type");
571 assertNotNull(metricType);
572 expectedQName = QName.create(UG_NS, UG_REV, "metric-type");
573 assertEquals(expectedQName, metricType.getQName());
574 path.offer(expectedQName);
575 expectedPath= SchemaPath.create(path, true);
576 assertEquals(expectedPath, metricType.getPath());
577 assertEquals(Uint8.getInstance(), metricType.getType());
578 assertTrue(metricType.isAddedByUses());
580 box = (ContainerSchemaNode) metric.getDataChildByName("box");
582 expectedQName = QName.create(UG_NS, UG_REV, "box");
583 assertEquals(expectedQName, box.getQName());
585 path.offer(expectedQName);
586 expectedPath= SchemaPath.create(path, true);
587 assertEquals(expectedPath, box.getPath());
588 assertTrue(box.isAddedByUses());
589 // * |-- |-- |-- leaf processing-rule
590 processingRule = (LeafSchemaNode) metric.getDataChildByName("processing-rule");
591 assertNotNull(processingRule);
592 expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
593 assertEquals(expectedQName, processingRule.getQName());
595 path.offer(expectedQName);
596 expectedPath= SchemaPath.create(path, true);
597 assertEquals(expectedPath, processingRule.getPath());
598 assertEquals(BooleanType.getInstance(), processingRule.getType());
599 assertTrue(processingRule.isAddedByUses());
600 // * |-- |-- |-- leaf ignore
601 ignore = (LeafSchemaNode) metric.getDataChildByName("ignore");
602 assertNotNull(ignore);
603 expectedQName = QName.create(UG_NS, UG_REV, "ignore");
604 assertEquals(expectedQName, ignore.getQName());
606 path.offer(expectedQName);
607 expectedPath= SchemaPath.create(path, true);
608 assertEquals(expectedPath, ignore.getPath());
609 assertEquals(BooleanType.getInstance(), ignore.getType());
610 assertTrue(ignore.isAddedByUses());
614 public void testTypedefs() throws URISyntaxException, SourceException, ReactorException {
615 modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
616 Module testModule = TestUtils.findModule(modules, "grouping-definitions");
617 Set<TypeDefinition<?>> types = testModule.getTypeDefinitions();
619 TypeDefinition<?> intExt = null;
620 for(TypeDefinition<?> td : types) {
621 if("int-ext".equals(td.getQName().getLocalName())) {
625 assertNotNull(intExt);
627 List<QName> path = Lists.newArrayList(QName.create(GD_NS, GD_REV, "int-ext"));
628 SchemaPath expectedPath = SchemaPath.create(path, true);
629 assertEquals(expectedPath, intExt.getPath());
631 UnionType union = (UnionType)intExt.getBaseType();
633 TypeDefinition<?> uint8 = null;
634 TypeDefinition<?> pv = null;
635 for(TypeDefinition<?> td : union.getTypes()) {
636 if("uint8".equals(td.getQName().getLocalName())) {
638 } else if("protocol-version".equals(td.getQName().getLocalName())) {
642 assertNotNull(uint8);
645 QName q1 = BaseTypes.constructQName("union");
646 expectedPath = SchemaPath.create(Lists.newArrayList(q1), true);
647 assertEquals(expectedPath, union.getPath());