2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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.model.util;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12 import static org.junit.jupiter.api.Assertions.assertSame;
14 import com.google.common.collect.Iterables;
15 import org.junit.jupiter.api.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.test.util.YangParserTestUtils;
22 private static final QName FOO = QName.create("foo", "foo");
23 private static final QName BAR = QName.create("foo", "bar");
24 private static final QName BAZ = QName.create("foo", "baz");
27 void testDeviatedEffectiveAugmentationSchema() {
28 final var module = YangParserTestUtils.parseYang("""
37 deviation /foo:foo/foo:baz {
38 deviate not-supported;
55 }""").findModule("foo").orElseThrow();
56 final var augment = Iterables.getOnlyElement(module.getAugmentations());
57 assertEquals(2, augment.getChildNodes().size());
58 assertInstanceOf(LeafSchemaNode.class, augment.dataChildByName(BAR));
59 assertInstanceOf(LeafSchemaNode.class, augment.dataChildByName(BAZ));
61 final var foo = assertInstanceOf(ContainerSchemaNode.class, module.getDataChildByName(FOO));
62 assertEquals(1, foo.getChildNodes().size());
63 assertInstanceOf(LeafSchemaNode.class, foo.dataChildByName(BAR));
65 assertSame(augment, Iterables.getOnlyElement(foo.getAvailableAugmentations()));