2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.List;
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.xpath.api.YangExpr;
20 import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath.Relative;
21 import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
23 public class YT1201Test extends AbstractYangTest {
24 private static final QName FOO = QName.create("foo", "foo");
25 private static final QName BAR = QName.create("foo", "bar");
28 public void testWhenPrefixes() {
29 final DataSchemaNode bar = assertEffectiveModelDir("/bugs/YT1201/").getDataChildByName(BAR);
30 assertThat(bar, instanceOf(ContainerSchemaNode.class));
31 final YangExpr when = ((ContainerSchemaNode) bar).getWhenCondition().get().getRootExpr();
32 assertThat(when, instanceOf(Relative.class));
33 assertEquals(List.of(YangXPathAxis.CHILD.asStep(FOO)), ((Relative) when).getSteps());