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.assertNotNull;
12 import static org.junit.Assert.assertThrows;
14 import java.util.Optional;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.common.Revision;
20 import org.opendaylight.yangtools.yang.common.XMLNamespace;
21 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
25 import org.opendaylight.yangtools.yang.model.api.Module;
26 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
27 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
29 public class CaseStmtTest {
30 private static final Optional<Boolean> OPT_FALSE = Optional.of(Boolean.FALSE);
31 private static final Optional<Boolean> OPT_TRUE = Optional.of(Boolean.TRUE);
33 private SchemaContext schema;
34 private Module rootFoo;
35 private Module rootBar;
36 private QNameModule qnameFoo;
37 private QNameModule qnameBar;
38 private DataSchemaNode tempChild;
39 private DataSchemaNode tempSecondChild;
40 private DataSchemaNode tempThirdChild;
41 private CaseSchemaNode tempChoice;
44 public void setup() throws Exception {
45 schema = StmtTestUtils.parseYangSources("/case-test");
46 Revision rev = Revision.of("2015-09-09");
47 rootFoo = schema.findModule("foo", rev).get();
48 rootBar = schema.findModule("bar", rev).get();
49 assertNotNull(rootFoo);
50 assertNotNull(rootBar);
51 qnameFoo = QNameModule.create(XMLNamespace.of("foo"), rev);
52 qnameBar = QNameModule.create(XMLNamespace.of("bar"), rev);
53 assertNotNull(qnameFoo);
54 assertNotNull(qnameBar);
58 public void caseTest() {
59 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fff"));
60 assertNotNull(tempChild);
61 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
62 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
63 assertNotNull(tempSecondChild);
64 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
65 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
66 assertNotNull(tempChoice);
67 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
68 tempThirdChild = tempChoice.getChildNodes().iterator().next();
69 assertNotNull(tempThirdChild);
70 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
72 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ffn"));
73 assertNotNull(tempChild);
74 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
75 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
76 assertNotNull(tempSecondChild);
77 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
78 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
79 assertNotNull(tempChoice);
80 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
81 tempThirdChild = tempChoice.getChildNodes().iterator().next();
82 assertNotNull(tempThirdChild);
83 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
85 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fnf"));
86 assertNotNull(tempChild);
87 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
88 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
89 assertNotNull(tempSecondChild);
90 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
91 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
92 assertNotNull(tempChoice);
93 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
94 tempThirdChild = tempChoice.getChildNodes().iterator().next();
95 assertNotNull(tempThirdChild);
96 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
98 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nff"));
99 assertNotNull(tempChild);
100 assertEquals(Optional.empty(), tempChild.effectiveConfig());
101 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
102 assertNotNull(tempSecondChild);
103 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
104 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
105 assertNotNull(tempChoice);
106 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
107 tempThirdChild = tempChoice.getChildNodes().iterator().next();
108 assertNotNull(tempThirdChild);
109 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
111 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nnf"));
112 assertNotNull(tempChild);
113 assertEquals(Optional.empty(), tempChild.effectiveConfig());
114 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
115 assertNotNull(tempSecondChild);
116 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
117 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
118 assertNotNull(tempChoice);
119 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
120 tempThirdChild = tempChoice.getChildNodes().iterator().next();
121 assertNotNull(tempThirdChild);
122 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
124 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nfn"));
125 assertNotNull(tempChild);
126 assertEquals(Optional.empty(), tempChild.effectiveConfig());
127 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
128 assertNotNull(tempSecondChild);
129 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
130 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
131 assertNotNull(tempChoice);
132 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
133 tempThirdChild = tempChoice.getChildNodes().iterator().next();
134 assertNotNull(tempThirdChild);
135 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
137 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fnn"));
138 assertNotNull(tempChild);
139 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
140 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
141 assertNotNull(tempSecondChild);
142 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
143 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
144 assertNotNull(tempChoice);
145 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
146 tempThirdChild = tempChoice.getChildNodes().iterator().next();
147 assertNotNull(tempThirdChild);
148 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
150 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ttt"));
151 assertNotNull(tempChild);
152 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
153 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
154 assertNotNull(tempSecondChild);
155 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
156 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
157 assertNotNull(tempChoice);
158 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
159 tempThirdChild = tempChoice.getChildNodes().iterator().next();
160 assertNotNull(tempThirdChild);
161 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
163 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ttn"));
164 assertNotNull(tempChild);
165 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
166 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
167 assertNotNull(tempSecondChild);
168 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
169 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
170 assertNotNull(tempChoice);
171 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
172 tempThirdChild = tempChoice.getChildNodes().iterator().next();
173 assertNotNull(tempThirdChild);
174 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
176 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnt"));
177 assertNotNull(tempChild);
178 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
179 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
180 assertNotNull(tempSecondChild);
181 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
182 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
183 assertNotNull(tempChoice);
184 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
185 tempThirdChild = tempChoice.getChildNodes().iterator().next();
186 assertNotNull(tempThirdChild);
187 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
189 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntt"));
190 assertNotNull(tempChild);
191 assertEquals(Optional.empty(), tempChild.effectiveConfig());
192 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
193 assertNotNull(tempSecondChild);
194 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
195 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
196 assertNotNull(tempChoice);
197 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
198 tempThirdChild = tempChoice.getChildNodes().iterator().next();
199 assertNotNull(tempThirdChild);
200 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
202 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nnt"));
203 assertNotNull(tempChild);
204 assertEquals(Optional.empty(), tempChild.effectiveConfig());
205 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
206 assertNotNull(tempSecondChild);
207 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
208 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
209 assertNotNull(tempChoice);
210 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
211 tempThirdChild = tempChoice.getChildNodes().iterator().next();
212 assertNotNull(tempThirdChild);
213 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
215 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntn"));
216 assertNotNull(tempChild);
217 assertEquals(Optional.empty(), tempChild.effectiveConfig());
218 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
219 assertNotNull(tempSecondChild);
220 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
221 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
222 assertNotNull(tempChoice);
223 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
224 tempThirdChild = tempChoice.getChildNodes().iterator().next();
225 assertNotNull(tempThirdChild);
226 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
228 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnn"));
229 assertNotNull(tempChild);
230 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
231 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
232 assertNotNull(tempSecondChild);
233 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
234 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
235 assertNotNull(tempChoice);
236 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
237 tempThirdChild = tempChoice.getChildNodes().iterator().next();
238 assertNotNull(tempThirdChild);
239 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
241 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tff"));
242 assertNotNull(tempChild);
243 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
244 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
245 assertNotNull(tempSecondChild);
246 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
247 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
248 assertNotNull(tempChoice);
249 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
250 tempThirdChild = tempChoice.getChildNodes().iterator().next();
251 assertNotNull(tempThirdChild);
252 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
254 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnf"));
255 assertNotNull(tempChild);
256 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
257 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
258 assertNotNull(tempSecondChild);
259 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
260 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
261 assertNotNull(tempChoice);
262 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
263 tempThirdChild = tempChoice.getChildNodes().iterator().next();
264 assertNotNull(tempThirdChild);
265 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
267 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tfn"));
268 assertNotNull(tempChild);
269 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
270 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
271 assertNotNull(tempSecondChild);
272 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
273 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
274 assertNotNull(tempChoice);
275 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
276 tempThirdChild = tempChoice.getChildNodes().iterator().next();
277 assertNotNull(tempThirdChild);
278 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
280 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntf"));
281 assertNotNull(tempChild);
282 assertEquals(Optional.empty(), tempChild.effectiveConfig());
283 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
284 assertNotNull(tempSecondChild);
285 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
286 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
287 assertNotNull(tempChoice);
288 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
289 tempThirdChild = tempChoice.getChildNodes().iterator().next();
290 assertNotNull(tempThirdChild);
291 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
295 public void shortCaseTest() {
296 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fff"));
297 assertNotNull(tempChild);
298 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
299 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
300 assertNotNull(tempSecondChild);
301 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
302 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
303 assertNotNull(tempChoice);
304 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
305 tempThirdChild = tempChoice.getChildNodes().iterator().next();
306 assertNotNull(tempThirdChild);
307 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
309 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ffn"));
310 assertNotNull(tempChild);
311 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
312 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
313 assertNotNull(tempSecondChild);
314 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
315 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
316 assertNotNull(tempChoice);
317 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
318 tempThirdChild = tempChoice.getChildNodes().iterator().next();
319 assertNotNull(tempThirdChild);
320 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
322 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fnf"));
323 assertNotNull(tempChild);
324 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
325 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
326 assertNotNull(tempSecondChild);
327 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
328 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
329 assertNotNull(tempChoice);
330 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
331 tempThirdChild = tempChoice.getChildNodes().iterator().next();
332 assertNotNull(tempThirdChild);
333 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
335 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nff"));
336 assertNotNull(tempChild);
337 assertEquals(Optional.empty(), tempChild.effectiveConfig());
338 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
339 assertNotNull(tempSecondChild);
340 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
341 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
342 assertNotNull(tempChoice);
343 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
344 tempThirdChild = tempChoice.getChildNodes().iterator().next();
345 assertNotNull(tempThirdChild);
346 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
348 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nnf"));
349 assertNotNull(tempChild);
350 assertEquals(Optional.empty(), tempChild.effectiveConfig());
351 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
352 assertNotNull(tempSecondChild);
353 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
354 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
355 assertNotNull(tempChoice);
356 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
357 tempThirdChild = tempChoice.getChildNodes().iterator().next();
358 assertNotNull(tempThirdChild);
359 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
361 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nfn"));
362 assertNotNull(tempChild);
363 assertEquals(Optional.empty(), tempChild.effectiveConfig());
364 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
365 assertNotNull(tempSecondChild);
366 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
367 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
368 assertNotNull(tempChoice);
369 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
370 tempThirdChild = tempChoice.getChildNodes().iterator().next();
371 assertNotNull(tempThirdChild);
372 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
374 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fnn"));
375 assertNotNull(tempChild);
376 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
377 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
378 assertNotNull(tempSecondChild);
379 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
380 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
381 assertNotNull(tempChoice);
382 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
383 tempThirdChild = tempChoice.getChildNodes().iterator().next();
384 assertNotNull(tempThirdChild);
385 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
387 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ttt"));
388 assertNotNull(tempChild);
389 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
390 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
391 assertNotNull(tempSecondChild);
392 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
393 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
394 assertNotNull(tempChoice);
395 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
396 tempThirdChild = tempChoice.getChildNodes().iterator().next();
397 assertNotNull(tempThirdChild);
398 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
400 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ttn"));
401 assertNotNull(tempChild);
402 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
403 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
404 assertNotNull(tempSecondChild);
405 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
406 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
407 assertNotNull(tempChoice);
408 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
409 tempThirdChild = tempChoice.getChildNodes().iterator().next();
410 assertNotNull(tempThirdChild);
411 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
413 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnt"));
414 assertNotNull(tempChild);
415 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
416 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
417 assertNotNull(tempSecondChild);
418 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
419 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
420 assertNotNull(tempChoice);
421 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
422 tempThirdChild = tempChoice.getChildNodes().iterator().next();
423 assertNotNull(tempThirdChild);
424 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
426 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntt"));
427 assertNotNull(tempChild);
428 assertEquals(Optional.empty(), tempChild.effectiveConfig());
429 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
430 assertNotNull(tempSecondChild);
431 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
432 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
433 assertNotNull(tempChoice);
434 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
435 tempThirdChild = tempChoice.getChildNodes().iterator().next();
436 assertNotNull(tempThirdChild);
437 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
439 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nnt"));
440 assertNotNull(tempChild);
441 assertEquals(Optional.empty(), tempChild.effectiveConfig());
442 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
443 assertNotNull(tempSecondChild);
444 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
445 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
446 assertNotNull(tempChoice);
447 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
448 tempThirdChild = tempChoice.getChildNodes().iterator().next();
449 assertNotNull(tempThirdChild);
450 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
452 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntn"));
453 assertNotNull(tempChild);
454 assertEquals(Optional.empty(), tempChild.effectiveConfig());
455 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
456 assertNotNull(tempSecondChild);
457 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
458 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
459 assertNotNull(tempChoice);
460 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
461 tempThirdChild = tempChoice.getChildNodes().iterator().next();
462 assertNotNull(tempThirdChild);
463 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
465 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnn"));
466 assertNotNull(tempChild);
467 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
468 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
469 assertNotNull(tempSecondChild);
470 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
471 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
472 assertNotNull(tempChoice);
473 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
474 tempThirdChild = tempChoice.getChildNodes().iterator().next();
475 assertNotNull(tempThirdChild);
476 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
478 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tff"));
479 assertNotNull(tempChild);
480 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
481 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
482 assertNotNull(tempSecondChild);
483 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
484 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
485 assertNotNull(tempChoice);
486 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
487 tempThirdChild = tempChoice.getChildNodes().iterator().next();
488 assertNotNull(tempThirdChild);
489 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
491 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnf"));
492 assertNotNull(tempChild);
493 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
494 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
495 assertNotNull(tempSecondChild);
496 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
497 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
498 assertNotNull(tempChoice);
499 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
500 tempThirdChild = tempChoice.getChildNodes().iterator().next();
501 assertNotNull(tempThirdChild);
502 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
504 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tfn"));
505 assertNotNull(tempChild);
506 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
507 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
508 assertNotNull(tempSecondChild);
509 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
510 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
511 assertNotNull(tempChoice);
512 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
513 tempThirdChild = tempChoice.getChildNodes().iterator().next();
514 assertNotNull(tempThirdChild);
515 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
517 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntf"));
518 assertNotNull(tempChild);
519 assertEquals(Optional.empty(), tempChild.effectiveConfig());
520 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
521 assertNotNull(tempSecondChild);
522 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
523 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
524 assertNotNull(tempChoice);
525 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
526 tempThirdChild = tempChoice.getChildNodes().iterator().next();
527 assertNotNull(tempThirdChild);
528 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
532 public void testInferenceExceptionChoice() {
533 assertThrows(ReactorException.class,
534 () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice"));
538 public void testInferenceExceptionCase() throws Exception {
539 assertThrows(ReactorException.class,
540 () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case"));