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;
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;
22 public class Bug5518Test {
24 public void test() throws Exception {
25 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5518");
26 assertNotNull(context);
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());