5ae4351b0c7b92346bceb3f28c4bc286357a4520
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / YT1200Test.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
13
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.DataSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
19
20 public class YT1200Test {
21     private static final QName FOO = QName.create("urn:foo", "foo");
22
23     @Test
24     public void testKeyParsing() throws Exception {
25         final DataSchemaNode foo = StmtTestUtils.parseYangSource("/bugs/YT1200/foo.yang").getDataChildByName(FOO);
26         assertThat(foo, instanceOf(ListSchemaNode.class));
27         assertEquals(List.of(FOO, QName.create(FOO, "bar"), QName.create(FOO, "baz")),
28             ((ListSchemaNode) foo).getKeyDefinition());
29     }
30 }