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.jupiter.api.Assertions.assertEquals;
14 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
15 import static org.junit.jupiter.api.Assertions.assertNotNull;
17 import org.junit.jupiter.api.Test;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.Module;
23 class Bug6240Test extends AbstractYangTest {
24 private static final String NS = "bar";
25 private static final String REV = "2016-07-19";
28 void testModels() throws Exception {
29 final var context = assertEffectiveModelDir("/bugs/bug6240/correct");
31 final var modules = context.getModules();
32 assertEquals(2, modules.size());
35 for (final Module module : modules) {
36 if ("bar".equals(module.getName())) {
43 assertInstanceOf(ContainerSchemaNode.class, bar.getDataChildByName(QName.create(NS, REV, "foo-grp-con")));
44 assertThat(bar.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")),
45 instanceOf(ContainerSchemaNode.class));
47 assertEquals(1, bar.getSubmodules().size());
49 final DataSchemaNode dataChildByName = bar.getDataChildByName(QName.create(NS, REV, "sub-bar-con"));
50 assertInstanceOf(ContainerSchemaNode.class, dataChildByName);
51 final ContainerSchemaNode subBarCon = (ContainerSchemaNode) dataChildByName;
53 assertThat(subBarCon.getDataChildByName(QName.create(NS, REV, "foo-grp-con")),
54 instanceOf(ContainerSchemaNode.class));
55 assertThat(subBarCon.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")),
56 instanceOf(ContainerSchemaNode.class));
60 void testInvalidModels() {
61 assertInferenceExceptionDir("/bugs/bug6240/incorrect",
62 startsWith("Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));