88c034f9c31a6f88862913276e462d6347f80ed2
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug5518Test.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.util.Collection;
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.MustDefinition;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21
22 public class Bug5518Test {
23     @Test
24     public void test() throws Exception {
25         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5518");
26         assertNotNull(context);
27
28         final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "root"));
29         assertTrue(dataChildByName instanceof ContainerSchemaNode);
30         final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
31         final Collection<? extends MustDefinition> mustConstraints = root.getMustConstraints();
32         assertEquals(1, mustConstraints.size());
33         final MustDefinition must = mustConstraints.iterator().next();
34         assertEquals("not(deref(.)/../same-pass)", must.getXpath().toString());
35     }
36 }