Remove deprecated Yin/YangStatementSourceImpl
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileTypeDefStmtTest.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.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.io.IOException;
14 import java.net.URISyntaxException;
15 import java.util.Iterator;
16 import java.util.Set;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
23 import org.opendaylight.yangtools.yang.stmt.TestUtils;
24 import org.xml.sax.SAXException;
25
26 public class YinFileTypeDefStmtTest {
27
28     private SchemaContext context;
29
30     @Before
31     public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
32         context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
33         assertEquals(9, context.getModules().size());
34     }
35
36     @Test
37     public void testTypedef() {
38         Module testModule = TestUtils.findModule(context, "config").get();
39         assertNotNull(testModule);
40
41         Set<TypeDefinition<?>> typeDefs = testModule.getTypeDefinitions();
42         assertEquals(1, typeDefs.size());
43
44         Iterator<TypeDefinition<?>> typeDefIterator = typeDefs.iterator();
45         TypeDefinition<?> typeDef = typeDefIterator.next();
46         assertEquals("service-type-ref", typeDef.getQName().getLocalName());
47         assertEquals("Internal type of references to service type identity.", typeDef.getDescription());
48         assertEquals("identityref", typeDef.getBaseType().getQName().getLocalName());
49     }
50 }