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.parser.stmt.rfc7950;
10 import static org.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.CoreMatchers.startsWith;
12 import static org.hamcrest.MatcherAssert.assertThat;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
18 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
20 public class Bug6876Test extends AbstractYangTest {
22 public void yang11Test() {
23 final var context = assertEffectiveModelDir("/rfc7950/bug6876/yang11");
24 DataSchemaNode node = context.findDataTreeChild(bar("augment-target"), bar("my-leaf")).orElse(null);
25 assertThat(node, instanceOf(LeafSchemaNode.class));
26 node = context.findDataTreeChild(bar("augment-target"), foo("mandatory-leaf")).orElse(null);
27 assertThat(node, instanceOf(LeafSchemaNode.class));
31 public void yang10Test() {
32 assertInferenceExceptionDir("/rfc7950/bug6876/yang10", startsWith(
33 "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
36 private static QName foo(final String localName) {
37 return QName.create("foo", localName);
40 private static QName bar(final String localName) {
41 return QName.create("bar", "2017-01-11", localName);