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.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
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.EffectiveModelContext;
26 import org.opendaylight.yangtools.yang.model.api.Module;
28 public class CaseStmtTest extends AbstractYangTest {
29 private static final Optional<Boolean> OPT_FALSE = Optional.of(Boolean.FALSE);
30 private static final Optional<Boolean> OPT_TRUE = Optional.of(Boolean.TRUE);
32 private EffectiveModelContext schema;
33 private Module rootFoo;
34 private Module rootBar;
35 private QNameModule qnameFoo;
36 private QNameModule qnameBar;
37 private DataSchemaNode tempChild;
38 private DataSchemaNode tempSecondChild;
39 private DataSchemaNode tempThirdChild;
40 private CaseSchemaNode tempChoice;
44 schema = assertEffectiveModelDir("/case-test");
45 Revision rev = Revision.of("2015-09-09");
46 rootFoo = schema.findModule("foo", rev).get();
47 rootBar = schema.findModule("bar", rev).get();
48 assertNotNull(rootFoo);
49 assertNotNull(rootBar);
50 qnameFoo = QNameModule.create(XMLNamespace.of("foo"), rev);
51 qnameBar = QNameModule.create(XMLNamespace.of("bar"), rev);
52 assertNotNull(qnameFoo);
53 assertNotNull(qnameBar);
57 public void caseTest() {
58 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fff"));
59 assertNotNull(tempChild);
60 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
61 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
62 assertNotNull(tempSecondChild);
63 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
64 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
65 assertNotNull(tempChoice);
66 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
67 tempThirdChild = tempChoice.getChildNodes().iterator().next();
68 assertNotNull(tempThirdChild);
69 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
71 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ffn"));
72 assertNotNull(tempChild);
73 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
74 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
75 assertNotNull(tempSecondChild);
76 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
77 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
78 assertNotNull(tempChoice);
79 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
80 tempThirdChild = tempChoice.getChildNodes().iterator().next();
81 assertNotNull(tempThirdChild);
82 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
84 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fnf"));
85 assertNotNull(tempChild);
86 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
87 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
88 assertNotNull(tempSecondChild);
89 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
90 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
91 assertNotNull(tempChoice);
92 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
93 tempThirdChild = tempChoice.getChildNodes().iterator().next();
94 assertNotNull(tempThirdChild);
95 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
97 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nff"));
98 assertNotNull(tempChild);
99 assertEquals(Optional.empty(), tempChild.effectiveConfig());
100 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
101 assertNotNull(tempSecondChild);
102 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
103 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
104 assertNotNull(tempChoice);
105 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
106 tempThirdChild = tempChoice.getChildNodes().iterator().next();
107 assertNotNull(tempThirdChild);
108 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
110 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nnf"));
111 assertNotNull(tempChild);
112 assertEquals(Optional.empty(), tempChild.effectiveConfig());
113 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
114 assertNotNull(tempSecondChild);
115 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
116 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
117 assertNotNull(tempChoice);
118 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
119 tempThirdChild = tempChoice.getChildNodes().iterator().next();
120 assertNotNull(tempThirdChild);
121 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
123 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nfn"));
124 assertNotNull(tempChild);
125 assertEquals(Optional.empty(), tempChild.effectiveConfig());
126 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
127 assertNotNull(tempSecondChild);
128 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
129 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
130 assertNotNull(tempChoice);
131 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
132 tempThirdChild = tempChoice.getChildNodes().iterator().next();
133 assertNotNull(tempThirdChild);
134 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
136 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fnn"));
137 assertNotNull(tempChild);
138 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
139 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
140 assertNotNull(tempSecondChild);
141 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
142 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
143 assertNotNull(tempChoice);
144 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
145 tempThirdChild = tempChoice.getChildNodes().iterator().next();
146 assertNotNull(tempThirdChild);
147 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
149 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ttt"));
150 assertNotNull(tempChild);
151 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
152 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
153 assertNotNull(tempSecondChild);
154 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
155 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
156 assertNotNull(tempChoice);
157 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
158 tempThirdChild = tempChoice.getChildNodes().iterator().next();
159 assertNotNull(tempThirdChild);
160 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
162 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ttn"));
163 assertNotNull(tempChild);
164 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
165 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
166 assertNotNull(tempSecondChild);
167 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
168 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
169 assertNotNull(tempChoice);
170 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
171 tempThirdChild = tempChoice.getChildNodes().iterator().next();
172 assertNotNull(tempThirdChild);
173 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
175 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnt"));
176 assertNotNull(tempChild);
177 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
178 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
179 assertNotNull(tempSecondChild);
180 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
181 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
182 assertNotNull(tempChoice);
183 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
184 tempThirdChild = tempChoice.getChildNodes().iterator().next();
185 assertNotNull(tempThirdChild);
186 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
188 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntt"));
189 assertNotNull(tempChild);
190 assertEquals(Optional.empty(), tempChild.effectiveConfig());
191 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
192 assertNotNull(tempSecondChild);
193 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
194 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
195 assertNotNull(tempChoice);
196 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
197 tempThirdChild = tempChoice.getChildNodes().iterator().next();
198 assertNotNull(tempThirdChild);
199 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
201 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-nnt"));
202 assertNotNull(tempChild);
203 assertEquals(Optional.empty(), tempChild.effectiveConfig());
204 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
205 assertNotNull(tempSecondChild);
206 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
207 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
208 assertNotNull(tempChoice);
209 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
210 tempThirdChild = tempChoice.getChildNodes().iterator().next();
211 assertNotNull(tempThirdChild);
212 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
214 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntn"));
215 assertNotNull(tempChild);
216 assertEquals(Optional.empty(), tempChild.effectiveConfig());
217 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
218 assertNotNull(tempSecondChild);
219 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
220 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
221 assertNotNull(tempChoice);
222 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
223 tempThirdChild = tempChoice.getChildNodes().iterator().next();
224 assertNotNull(tempThirdChild);
225 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
227 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnn"));
228 assertNotNull(tempChild);
229 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
230 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
231 assertNotNull(tempSecondChild);
232 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
233 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
234 assertNotNull(tempChoice);
235 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
236 tempThirdChild = tempChoice.getChildNodes().iterator().next();
237 assertNotNull(tempThirdChild);
238 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
240 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tff"));
241 assertNotNull(tempChild);
242 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
243 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
244 assertNotNull(tempSecondChild);
245 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
246 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
247 assertNotNull(tempChoice);
248 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
249 tempThirdChild = tempChoice.getChildNodes().iterator().next();
250 assertNotNull(tempThirdChild);
251 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
253 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tnf"));
254 assertNotNull(tempChild);
255 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
256 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
257 assertNotNull(tempSecondChild);
258 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
259 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
260 assertNotNull(tempChoice);
261 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
262 tempThirdChild = tempChoice.getChildNodes().iterator().next();
263 assertNotNull(tempThirdChild);
264 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
266 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-tfn"));
267 assertNotNull(tempChild);
268 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
269 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
270 assertNotNull(tempSecondChild);
271 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
272 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
273 assertNotNull(tempChoice);
274 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
275 tempThirdChild = tempChoice.getChildNodes().iterator().next();
276 assertNotNull(tempThirdChild);
277 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
279 tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-ntf"));
280 assertNotNull(tempChild);
281 assertEquals(Optional.empty(), tempChild.effectiveConfig());
282 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
283 assertNotNull(tempSecondChild);
284 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
285 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
286 assertNotNull(tempChoice);
287 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
288 tempThirdChild = tempChoice.getChildNodes().iterator().next();
289 assertNotNull(tempThirdChild);
290 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
294 public void shortCaseTest() {
295 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fff"));
296 assertNotNull(tempChild);
297 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
298 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
299 assertNotNull(tempSecondChild);
300 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
301 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
302 assertNotNull(tempChoice);
303 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
304 tempThirdChild = tempChoice.getChildNodes().iterator().next();
305 assertNotNull(tempThirdChild);
306 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
308 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ffn"));
309 assertNotNull(tempChild);
310 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
311 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
312 assertNotNull(tempSecondChild);
313 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
314 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
315 assertNotNull(tempChoice);
316 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
317 tempThirdChild = tempChoice.getChildNodes().iterator().next();
318 assertNotNull(tempThirdChild);
319 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
321 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fnf"));
322 assertNotNull(tempChild);
323 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
324 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
325 assertNotNull(tempSecondChild);
326 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
327 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
328 assertNotNull(tempChoice);
329 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
330 tempThirdChild = tempChoice.getChildNodes().iterator().next();
331 assertNotNull(tempThirdChild);
332 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
334 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nff"));
335 assertNotNull(tempChild);
336 assertEquals(Optional.empty(), tempChild.effectiveConfig());
337 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
338 assertNotNull(tempSecondChild);
339 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
340 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
341 assertNotNull(tempChoice);
342 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
343 tempThirdChild = tempChoice.getChildNodes().iterator().next();
344 assertNotNull(tempThirdChild);
345 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
347 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nnf"));
348 assertNotNull(tempChild);
349 assertEquals(Optional.empty(), tempChild.effectiveConfig());
350 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
351 assertNotNull(tempSecondChild);
352 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
353 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
354 assertNotNull(tempChoice);
355 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
356 tempThirdChild = tempChoice.getChildNodes().iterator().next();
357 assertNotNull(tempThirdChild);
358 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
360 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nfn"));
361 assertNotNull(tempChild);
362 assertEquals(Optional.empty(), tempChild.effectiveConfig());
363 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
364 assertNotNull(tempSecondChild);
365 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
366 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
367 assertNotNull(tempChoice);
368 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
369 tempThirdChild = tempChoice.getChildNodes().iterator().next();
370 assertNotNull(tempThirdChild);
371 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
373 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fnn"));
374 assertNotNull(tempChild);
375 assertEquals(OPT_FALSE, tempChild.effectiveConfig());
376 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
377 assertNotNull(tempSecondChild);
378 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
379 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
380 assertNotNull(tempChoice);
381 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
382 tempThirdChild = tempChoice.getChildNodes().iterator().next();
383 assertNotNull(tempThirdChild);
384 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
386 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ttt"));
387 assertNotNull(tempChild);
388 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
389 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
390 assertNotNull(tempSecondChild);
391 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
392 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
393 assertNotNull(tempChoice);
394 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
395 tempThirdChild = tempChoice.getChildNodes().iterator().next();
396 assertNotNull(tempThirdChild);
397 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
399 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ttn"));
400 assertNotNull(tempChild);
401 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
402 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
403 assertNotNull(tempSecondChild);
404 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
405 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
406 assertNotNull(tempChoice);
407 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
408 tempThirdChild = tempChoice.getChildNodes().iterator().next();
409 assertNotNull(tempThirdChild);
410 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
412 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnt"));
413 assertNotNull(tempChild);
414 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
415 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
416 assertNotNull(tempSecondChild);
417 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
418 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
419 assertNotNull(tempChoice);
420 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
421 tempThirdChild = tempChoice.getChildNodes().iterator().next();
422 assertNotNull(tempThirdChild);
423 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
425 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntt"));
426 assertNotNull(tempChild);
427 assertEquals(Optional.empty(), tempChild.effectiveConfig());
428 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
429 assertNotNull(tempSecondChild);
430 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
431 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
432 assertNotNull(tempChoice);
433 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
434 tempThirdChild = tempChoice.getChildNodes().iterator().next();
435 assertNotNull(tempThirdChild);
436 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
438 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-nnt"));
439 assertNotNull(tempChild);
440 assertEquals(Optional.empty(), tempChild.effectiveConfig());
441 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
442 assertNotNull(tempSecondChild);
443 assertEquals(Optional.empty(), tempSecondChild.effectiveConfig());
444 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
445 assertNotNull(tempChoice);
446 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
447 tempThirdChild = tempChoice.getChildNodes().iterator().next();
448 assertNotNull(tempThirdChild);
449 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
451 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntn"));
452 assertNotNull(tempChild);
453 assertEquals(Optional.empty(), tempChild.effectiveConfig());
454 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
455 assertNotNull(tempSecondChild);
456 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
457 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
458 assertNotNull(tempChoice);
459 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
460 tempThirdChild = tempChoice.getChildNodes().iterator().next();
461 assertNotNull(tempThirdChild);
462 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
464 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnn"));
465 assertNotNull(tempChild);
466 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
467 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
468 assertNotNull(tempSecondChild);
469 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
470 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
471 assertNotNull(tempChoice);
472 assertEquals(OPT_TRUE, tempChoice.effectiveConfig());
473 tempThirdChild = tempChoice.getChildNodes().iterator().next();
474 assertNotNull(tempThirdChild);
475 assertEquals(OPT_TRUE, tempThirdChild.effectiveConfig());
477 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tff"));
478 assertNotNull(tempChild);
479 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
480 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
481 assertNotNull(tempSecondChild);
482 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
483 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
484 assertNotNull(tempChoice);
485 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
486 tempThirdChild = tempChoice.getChildNodes().iterator().next();
487 assertNotNull(tempThirdChild);
488 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
490 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tnf"));
491 assertNotNull(tempChild);
492 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
493 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
494 assertNotNull(tempSecondChild);
495 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
496 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
497 assertNotNull(tempChoice);
498 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
499 tempThirdChild = tempChoice.getChildNodes().iterator().next();
500 assertNotNull(tempThirdChild);
501 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
503 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-tfn"));
504 assertNotNull(tempChild);
505 assertEquals(OPT_TRUE, tempChild.effectiveConfig());
506 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
507 assertNotNull(tempSecondChild);
508 assertEquals(OPT_FALSE, tempSecondChild.effectiveConfig());
509 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
510 assertNotNull(tempChoice);
511 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
512 tempThirdChild = tempChoice.getChildNodes().iterator().next();
513 assertNotNull(tempThirdChild);
514 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
516 tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-ntf"));
517 assertNotNull(tempChild);
518 assertEquals(Optional.empty(), tempChild.effectiveConfig());
519 tempSecondChild = ((ContainerSchemaNode) tempChild).getChildNodes().iterator().next();
520 assertNotNull(tempSecondChild);
521 assertEquals(OPT_TRUE, tempSecondChild.effectiveConfig());
522 tempChoice = ((ChoiceSchemaNode) tempSecondChild).getCases().iterator().next();
523 assertNotNull(tempChoice);
524 assertEquals(OPT_FALSE, tempChoice.effectiveConfig());
525 tempThirdChild = tempChoice.getChildNodes().iterator().next();
526 assertNotNull(tempThirdChild);
527 assertEquals(OPT_FALSE, tempThirdChild.effectiveConfig());
531 public void testInferenceExceptionChoice() {
532 assertInferenceExceptionDir("/case-test/case-test-exceptions/choice",
533 startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));
537 public void testInferenceExceptionCase() {
538 assertInferenceExceptionDir("/case-test/case-test-exceptions/case",
539 startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));