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.startsWith;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
13 import org.junit.jupiter.api.Test;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
17 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
19 class Bug6876Test extends AbstractYangTest {
22 final var context = assertEffectiveModelDir("/rfc7950/bug6876/yang11");
23 DataSchemaNode node = context.findDataTreeChild(bar("augment-target"), bar("my-leaf")).orElse(null);
24 assertInstanceOf(LeafSchemaNode.class, node);
25 node = context.findDataTreeChild(bar("augment-target"), foo("mandatory-leaf")).orElse(null);
26 assertInstanceOf(LeafSchemaNode.class, node);
31 assertInferenceExceptionDir("/rfc7950/bug6876/yang10", startsWith(
32 "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
35 private static QName foo(final String localName) {
36 return QName.create("foo", localName);
39 private static QName bar(final String localName) {
40 return QName.create("bar", "2017-01-11", localName);