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