2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.stmt.yin;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import java.io.IOException;
14 import java.net.URISyntaxException;
15 import java.util.Iterator;
16 import java.util.Optional;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
24 import org.opendaylight.yangtools.yang.stmt.TestUtils;
25 import org.xml.sax.SAXException;
27 public class YinFileTypeDefStmtTest {
29 private SchemaContext context;
32 public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
33 context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
34 assertEquals(9, context.getModules().size());
38 public void testTypedef() {
39 Module testModule = TestUtils.findModule(context, "config").get();
40 assertNotNull(testModule);
42 Set<TypeDefinition<?>> typeDefs = testModule.getTypeDefinitions();
43 assertEquals(1, typeDefs.size());
45 Iterator<TypeDefinition<?>> typeDefIterator = typeDefs.iterator();
46 TypeDefinition<?> typeDef = typeDefIterator.next();
47 assertEquals("service-type-ref", typeDef.getQName().getLocalName());
48 assertEquals(Optional.of("Internal type of references to service type identity."), typeDef.getDescription());
49 assertEquals("identityref", typeDef.getBaseType().getQName().getLocalName());