2 * Copyright (c) 2018 Pantheon Technologies, 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.data.util;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertTrue;
13 import java.util.Optional;
14 import org.junit.jupiter.api.AfterAll;
15 import org.junit.jupiter.api.BeforeAll;
16 import org.junit.jupiter.api.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
22 class DataSchemaContextTreeTest {
23 private static final QNameModule MODULE = QNameModule.of("dataschemacontext");
24 private static final QName FOO = QName.create(MODULE, "foo");
25 private static final QName BAR = QName.create(MODULE, "bar");
26 private static final QName BAZ = QName.create(MODULE, "baz");
27 private static DataSchemaContextTree CONTEXT;
31 CONTEXT = DataSchemaContextTree.from(YangParserTestUtils.parseYang("""
32 module dataschemacontext {
33 namespace "dataschemacontext";
47 static void cleanup() {
52 void testCorrectInput() {
53 assertTrue(CONTEXT.findChild(YangInstanceIdentifier.of(FOO)).isPresent());
54 assertTrue(CONTEXT.findChild(YangInstanceIdentifier.of(FOO, BAR)).isPresent());
55 assertTrue(CONTEXT.findChild(YangInstanceIdentifier.of(FOO, BAR, BAZ)).isPresent());
59 void testSimpleBad() {
60 assertEquals(Optional.empty(), CONTEXT.findChild(YangInstanceIdentifier.of(BAR)));
64 void testNestedBad() {
65 assertEquals(Optional.empty(), CONTEXT.findChild(YangInstanceIdentifier.of(BAR, BAZ)));