2 * Copyright (c) 2015 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.test;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
18 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
23 public class TypedefSubStmtsTest {
25 private static final YangStatementSourceImpl FOOBAR = new YangStatementSourceImpl
26 ("/typedef-substmts-test/typedef-substmts-test.yang", false);
29 public void typedefSubStmtsTest() throws ReactorException {
30 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
31 StmtTestUtils.addSources(reactor, FOOBAR);
33 EffectiveSchemaContext result = reactor.buildEffective();
34 assertNotNull(result);
36 Set<TypeDefinition<?>> typedefs = result.getTypeDefinitions();
37 assertEquals(1, typedefs.size());
39 TypeDefinition<?> typedef = typedefs.iterator().next();
40 assertEquals("time-of-the-day", typedef.getQName().getLocalName());
41 assertEquals("string", typedef.getBaseType().getQName().getLocalName());
42 assertEquals("24-hour-clock", typedef.getUnits());
43 assertEquals("1am", typedef.getDefaultValue().toString());