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.assertTrue;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
23 public class Bug6240Test {
24 private static final String NS = "bar";
25 private static final String REV = "2016-07-19";
28 public void testModels() throws Exception {
29 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6240/correct");
30 assertNotNull(context);
32 final Set<Module> modules = context.getModules();
33 assertEquals(2, modules.size());
36 for (final Module module : modules) {
37 if ("bar".equals(module.getName())) {
44 assertTrue(bar.getDataChildByName(QName.create(NS, REV, "foo-grp-con")) instanceof ContainerSchemaNode);
45 assertTrue(bar.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")) instanceof ContainerSchemaNode);
47 assertEquals(1, bar.getSubmodules().size());
49 final DataSchemaNode dataChildByName = bar.getDataChildByName(QName.create(NS, REV, "sub-bar-con"));
50 assertTrue(dataChildByName instanceof ContainerSchemaNode);
51 final ContainerSchemaNode subBarCon = (ContainerSchemaNode) dataChildByName;
53 assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "foo-grp-con")) instanceof ContainerSchemaNode);
54 assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con"))
55 instanceof ContainerSchemaNode);
59 public void testInvalidModels() throws Exception {
61 StmtTestUtils.parseYangSources("/bugs/bug6240/incorrect");
62 } catch (final SomeModifiersUnresolvedException e) {
63 assertTrue(e.getCause().getCause().getMessage().startsWith(
64 "Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));