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.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.collect.ImmutableList;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
22 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
24 public class Bug7879Test {
25 private static final String NS = "my-model-ns";
28 public void test() throws Exception {
29 final SchemaContext context = TestUtils.parseYangSources("/bugs/bug7879");
30 assertNotNull(context);
32 assertTrue(findNode(context, ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-container")))
33 instanceof ContainerSchemaNode);
34 final SchemaNode myEventValueLeaf = findNode(context,
35 ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-value")));
36 assertTrue(myEventValueLeaf instanceof LeafSchemaNode);
37 assertEquals("new description", myEventValueLeaf.getDescription());
40 private static SchemaNode findNode(final SchemaContext context, final Iterable<QName> qNames) {
41 return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true));
44 private static QName qN(final String localName) {
45 return QName.create(NS, localName);