2 * Copyright (c) 2017 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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
14 import java.util.Optional;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.common.XMLNamespace;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
23 public class Bug7879Test extends AbstractYangTest {
24 private static final XMLNamespace NS = XMLNamespace.of("my-model-ns");
27 public void test() throws Exception {
28 final ModuleEffectiveStatement module = assertEffectiveModelDir("/bugs/bug7879")
29 .getModuleStatement(qn("my-model"));
31 final SchemaTreeEffectiveStatement<?> container = module.findSchemaTreeNode(
32 qn("my-alarm"), qn("my-content"), qn("my-event-container")).orElse(null);
33 assertThat(container, instanceOf(ContainerSchemaNode.class));
35 final SchemaTreeEffectiveStatement<?> leaf = module.findSchemaTreeNode(
36 qn("my-alarm"), qn("my-content"), qn("my-event-value")).orElse(null);
37 assertThat(leaf, instanceOf(LeafSchemaNode.class));
38 assertEquals(Optional.of("new description"), ((LeafSchemaNode) leaf).getDescription());
41 private static QName qn(final String localName) {
42 return QName.create(NS, localName);