2 * Copyright (c) 2021 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;
13 import com.google.common.collect.Iterables;
14 import java.util.Optional;
15 import org.junit.jupiter.api.BeforeAll;
16 import org.junit.jupiter.api.BeforeEach;
17 import org.junit.jupiter.api.Test;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ActionEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
22 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
24 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
27 private static final QName FOO = QName.create("foo", "foo");
28 private static final QName BAR = QName.create("foo", "bar");
29 private static final QName BAZ = QName.create("foo", "baz");
31 private static ModuleEffectiveStatement module;
33 private ContainerEffectiveStatement baz;
36 static void beforeClass() {
37 module = Iterables.getOnlyElement(YangParserTestUtils.parseYang("""
51 }""").getModuleStatements()
57 baz = assertInstanceOf(ContainerEffectiveStatement.class, module.findDataTreeNode(BAZ).orElseThrow());
62 assertEquals(Optional.empty(), module.findDataTreeNode(FOO));
63 assertInstanceOf(RpcEffectiveStatement.class, module.findSchemaTreeNode(FOO).orElseThrow());
67 void testNotification() {
68 assertEquals(Optional.empty(), module.findDataTreeNode(BAR));
69 assertInstanceOf(NotificationEffectiveStatement.class, module.findSchemaTreeNode(BAR).orElseThrow());
71 assertEquals(Optional.empty(), baz.findDataTreeNode(BAR));
72 assertInstanceOf(NotificationEffectiveStatement.class, baz.findSchemaTreeNode(BAR).orElseThrow());
77 assertEquals(Optional.empty(), baz.findDataTreeNode(FOO));
78 assertInstanceOf(ActionEffectiveStatement.class, baz.findSchemaTreeNode(FOO).orElseThrow());