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
9 package org.opendaylight.yangtools.yang.stmt;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
19 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
20 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
24 public class TypedefSubStmtsTest {
26 private static final StatementStreamSource FOOBAR = sourceForResource(
27 "/typedef-substmts-test/typedef-substmts-test.yang");
30 public void typedefSubStmtsTest() throws ReactorException {
31 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
32 reactor.addSources(FOOBAR);
34 EffectiveSchemaContext result = reactor.buildEffective();
35 assertNotNull(result);
37 Set<TypeDefinition<?>> typedefs = result.getTypeDefinitions();
38 assertEquals(1, typedefs.size());
40 TypeDefinition<?> typedef = typedefs.iterator().next();
41 assertEquals("time-of-the-day", typedef.getQName().getLocalName());
42 assertEquals("string", typedef.getBaseType().getQName().getLocalName());
43 assertEquals("24-hour-clock", typedef.getUnits());
44 assertEquals("1am", typedef.getDefaultValue().toString());