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