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.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
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;
21 public class Bug5518Test extends AbstractYangTest {
24 final var context = assertEffectiveModelDir("/bugs/bug5518");
25 final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "root"));
26 assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
27 final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
28 final Collection<? extends MustDefinition> mustConstraints = root.getMustConstraints();
29 assertEquals(1, mustConstraints.size());
30 final MustDefinition must = mustConstraints.iterator().next();
31 assertEquals("not(deref(.)/../same-pass)", must.getXpath().toString());