Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-parser-rfc7950 / 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.util.Iterator;
14 import java.util.Optional;
15 import java.util.Set;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
19 import org.opendaylight.yangtools.yang.stmt.TestUtils;
20
21 public class YinFileTypeDefStmtTest extends AbstractYinModulesTest {
22
23     @Test
24     public void testTypedef() {
25         Module testModule = TestUtils.findModule(context, "config").get();
26         assertNotNull(testModule);
27
28         Set<TypeDefinition<?>> typeDefs = testModule.getTypeDefinitions();
29         assertEquals(1, typeDefs.size());
30
31         Iterator<TypeDefinition<?>> typeDefIterator = typeDefs.iterator();
32         TypeDefinition<?> typeDef = typeDefIterator.next();
33         assertEquals("service-type-ref", typeDef.getQName().getLocalName());
34         assertEquals(Optional.of("Internal type of references to service type identity."), typeDef.getDescription());
35         assertEquals("identityref", typeDef.getBaseType().getQName().getLocalName());
36     }
37 }