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.MatcherAssert.assertThat;
11 import static org.hamcrest.Matchers.isA;
13 import java.util.Iterator;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.Revision;
17 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.Module;
24 public class Bug5884Test extends AbstractYangTest {
25 private static final String NS = "urn:yang.foo";
26 private static final String REV = "2016-01-01";
29 public void testBug5884() {
30 final var context = assertEffectiveModelDir("/bugs/bug5884");
32 final QName root = QName.create(NS, REV, "main-container");
33 final QName choice = QName.create(NS, REV, "test-choice");
34 final QName testContainerQname = QName.create(NS, REV, "test");
35 final Module foo = context.findModule("foo", Revision.of("2016-01-01")).get();
36 final ContainerSchemaNode rootContainer = (ContainerSchemaNode) context.getDataChildByName(root);
37 final ContainerSchemaNode testContainer = (ContainerSchemaNode) rootContainer.getDataChildByName(
39 final ChoiceSchemaNode dataChildByName = (ChoiceSchemaNode) testContainer.getDataChildByName(choice);
41 testIterator(foo.getAugmentations().iterator());
42 testIterator(dataChildByName.getAvailableAugmentations().iterator());
45 private static void testIterator(final Iterator<? extends AugmentationSchemaNode> iterator) {
46 while (iterator.hasNext()) {
47 AugmentationSchemaNode allAugments = iterator.next();
48 final DataSchemaNode currentChoice = allAugments.getChildNodes().iterator().next();
49 assertThat(currentChoice, isA(CaseSchemaNode.class));