Populate xpath/ hierarchy
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileIdentityStmtTest.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.yin;
9
10 import static org.hamcrest.CoreMatchers.anyOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.hamcrest.core.Is.is;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15 import static org.junit.Assert.assertTrue;
16
17 import java.net.URISyntaxException;
18 import java.util.Collection;
19 import java.util.Iterator;
20 import org.junit.Test;
21 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23 import org.opendaylight.yangtools.yang.stmt.TestUtils;
24
25 public class YinFileIdentityStmtTest extends AbstractYinModulesTest {
26
27     @Test
28     public void testIdentity() throws URISyntaxException {
29         Module testModule = TestUtils.findModule(context, "config").get();
30         assertNotNull(testModule);
31
32         Collection<? extends IdentitySchemaNode> identities = testModule.getIdentities();
33         assertEquals(2, identities.size());
34
35         Iterator<? extends IdentitySchemaNode> idIterator = identities.iterator();
36         IdentitySchemaNode id = idIterator.next();
37
38         assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
39         assertTrue(id.getBaseIdentities().isEmpty());
40
41         id = idIterator.next();
42         assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
43         assertTrue(id.getBaseIdentities().isEmpty());
44     }
45 }