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.instanceOf;
11 import static org.hamcrest.CoreMatchers.startsWith;
12 import static org.hamcrest.MatcherAssert.assertThat;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.Module;
22 public class Bug6240Test extends AbstractYangTest {
23 private static final String NS = "bar";
24 private static final String REV = "2016-07-19";
27 public void testModels() throws Exception {
28 final var context = assertEffectiveModelDir("/bugs/bug6240/correct");
30 final var modules = context.getModules();
31 assertEquals(2, modules.size());
34 for (final Module module : modules) {
35 if ("bar".equals(module.getName())) {
42 assertThat(bar.getDataChildByName(QName.create(NS, REV, "foo-grp-con")), instanceOf(ContainerSchemaNode.class));
43 assertThat(bar.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")),
44 instanceOf(ContainerSchemaNode.class));
46 assertEquals(1, bar.getSubmodules().size());
48 final DataSchemaNode dataChildByName = bar.getDataChildByName(QName.create(NS, REV, "sub-bar-con"));
49 assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
50 final ContainerSchemaNode subBarCon = (ContainerSchemaNode) dataChildByName;
52 assertThat(subBarCon.getDataChildByName(QName.create(NS, REV, "foo-grp-con")),
53 instanceOf(ContainerSchemaNode.class));
54 assertThat(subBarCon.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")),
55 instanceOf(ContainerSchemaNode.class));
59 public void testInvalidModels() {
60 assertInferenceExceptionDir("/bugs/bug6240/incorrect",
61 startsWith("Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));