Remove more TestUtils classes
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / TypedefSubStmtsTest.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;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
13
14 import java.util.Collection;
15 import java.util.Optional;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
21
22 public class TypedefSubStmtsTest {
23
24     @Test
25     public void typedefSubStmtsTest() throws ReactorException {
26         SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
27                 .addSource(sourceForResource("/typedef-substmts-test/typedef-substmts-test.yang"))
28                 .buildEffective();
29         assertNotNull(result);
30
31         Collection<? extends TypeDefinition<?>> typedefs = result.getTypeDefinitions();
32         assertEquals(1, typedefs.size());
33
34         TypeDefinition<?> typedef = typedefs.iterator().next();
35         assertEquals("time-of-the-day", typedef.getQName().getLocalName());
36         assertEquals("string", typedef.getBaseType().getQName().getLocalName());
37         assertEquals(Optional.of("24-hour-clock"), typedef.getUnits());
38         assertEquals("1am", typedef.getDefaultValue().map(Object::toString).orElse(null));
39     }
40 }