Deprecate simple DataTreeFactory.create()
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug7879Test.java
1 /*
2  * Copyright (c) 2017 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 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12
13 import java.util.Optional;
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.XMLNamespace;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
19
20 class Bug7879Test extends AbstractYangTest {
21     private static final XMLNamespace NS = XMLNamespace.of("my-model-ns");
22
23     @Test
24     void test() throws Exception {
25         final var module = assertEffectiveModelDir("/bugs/bug7879").getModuleStatement(qn("my-model"));
26
27         assertInstanceOf(ContainerSchemaNode.class, module.findSchemaTreeNode(
28             qn("my-alarm"), qn("my-content"), qn("my-event-container")).orElseThrow());
29
30         assertEquals(Optional.of("new description"),
31             assertInstanceOf(LeafSchemaNode.class, module.findSchemaTreeNode(
32                 qn("my-alarm"), qn("my-content"), qn("my-event-value")).orElseThrow()).getDescription());
33     }
34
35     private static QName qn(final String localName) {
36         return QName.create(NS, localName);
37     }
38 }