Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / 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.core.Is.is;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertThat;
15 import static org.junit.Assert.assertTrue;
16
17 import java.io.IOException;
18 import java.net.URISyntaxException;
19 import java.util.Iterator;
20 import java.util.Set;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.Module;
25 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
27 import org.opendaylight.yangtools.yang.stmt.TestUtils;
28 import org.xml.sax.SAXException;
29
30 public class YinFileIdentityStmtTest {
31
32     private SchemaContext context;
33
34     @Before
35     public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
36         context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
37         assertEquals(9, context.getModules().size());
38     }
39
40     @Test
41     public void testIdentity() throws URISyntaxException {
42         Module testModule = TestUtils.findModule(context, "config").get();
43         assertNotNull(testModule);
44
45         Set<IdentitySchemaNode> identities = testModule.getIdentities();
46         assertEquals(2, identities.size());
47
48         Iterator<IdentitySchemaNode> idIterator = identities.iterator();
49         IdentitySchemaNode id = idIterator.next();
50
51         assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
52         assertTrue(id.getBaseIdentities().isEmpty());
53
54         id = idIterator.next();
55         assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
56         assertTrue(id.getBaseIdentities().isEmpty());
57     }
58 }