2 * Copyright (c) 2016 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.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.LeafSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
20 public class Bug6669Test extends AbstractYangTest {
21 private static final String REV = "2016-09-08";
22 private static final String FOO_NS = "foo";
23 private static final String BAR_NS = "bar";
24 private static final QName ROOT = QName.create(FOO_NS, REV, "root");
25 private static final QName BAR = QName.create(BAR_NS, REV, "bar");
26 private static final QName BAR_1 = QName.create(BAR_NS, REV, "bar1");
27 private static final QName BAR_2 = QName.create(BAR_NS, REV, "bar2");
28 private static final QName M = QName.create(BAR_NS, REV, "m");
31 public void testInvalidAugment() {
32 assertInferenceExceptionDir("/bugs/bug6669/invalid/test1", startsWith(
33 "An augment cannot add node 'm' because it is mandatory and in module different than target"));
37 public void testInvalidAugment2() {
38 assertInferenceExceptionDir("/bugs/bug6669/invalid/test2", startsWith(
39 "An augment cannot add node 'm' because it is mandatory and in module different than target"));
43 public void testInvalidAugment3() {
44 assertInferenceExceptionDir("/bugs/bug6669/invalid/test3", startsWith(
45 "An augment cannot add node 'l' because it is mandatory and in module different than target"));
49 public void testValidAugment() {
50 final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test1");
51 final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, M).get();
52 assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
56 public void testValidAugment2() {
57 final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test2");
58 final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2, M).get();
59 assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
63 public void testValidAugment3() throws Exception {
64 final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test3");
65 final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2,
66 QName.create(BAR_NS, REV, "l")).get();
67 assertThat(findDataSchemaNode, instanceOf(ListSchemaNode.class));