Port yang-parser-rfc7950 to JUnit 5
[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.jupiter.api.Assertions.assertEquals;
11
12 import java.util.Optional;
13 import org.junit.jupiter.api.Test;
14
15 class TypedefSubStmtsTest extends AbstractYangTest {
16     @Test
17     void typedefSubStmtsTest() {
18         final var result = assertEffectiveModel("/typedef-substmts-test/typedef-substmts-test.yang");
19
20         final var typedefs = result.getTypeDefinitions();
21         assertEquals(1, typedefs.size());
22
23         final var typedef = typedefs.iterator().next();
24         assertEquals("time-of-the-day", typedef.getQName().getLocalName());
25         assertEquals("string", typedef.getBaseType().getQName().getLocalName());
26         assertEquals(Optional.of("24-hour-clock"), typedef.getUnits());
27         assertEquals("1am", typedef.getDefaultValue().map(Object::toString).orElseThrow());
28     }
29 }