2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2024 Ericsson
4 * Modifications Copyright (C) 2024 OpenInfra Foundation Europe
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
21 package org.oran.smo.yangtools.parser.model.statements.ietf.test;
23 import static org.junit.Assert.assertNull;
24 import static org.junit.Assert.assertTrue;
26 import java.util.Arrays;
28 import org.junit.Test;
30 import org.oran.smo.yangtools.parser.model.statements.ietf.CIETF;
31 import org.oran.smo.yangtools.parser.model.statements.ietf.YIetfAnnotation;
32 import org.oran.smo.yangtools.parser.model.statements.ietf.YIetfDefaultDenyAll;
33 import org.oran.smo.yangtools.parser.model.statements.ietf.YIetfDefaultDenyWrite;
34 import org.oran.smo.yangtools.parser.model.statements.threegpp.C3GPP;
35 import org.oran.smo.yangtools.parser.model.statements.threegpp.Y3gppInVariant;
36 import org.oran.smo.yangtools.parser.model.statements.threegpp.Y3gppInitialValue;
37 import org.oran.smo.yangtools.parser.model.statements.threegpp.Y3gppNotNotifyable;
38 import org.oran.smo.yangtools.parser.model.statements.yang.YContainer;
39 import org.oran.smo.yangtools.parser.model.statements.yang.YLeaf;
40 import org.oran.smo.yangtools.parser.model.statements.yang.YModule;
41 import org.oran.smo.yangtools.parser.testutils.YangTestCommon;
43 public class OtherExtensionsTest extends YangTestCommon {
45 private static final String IETF_YANG_METADATA = "ietf-yang-metadata";
46 private static final String THREE_GPP_COMMON_YANG_EXTENSIONS = "_3gpp-common-yang-extensions";
47 private static final String IETF_NETCONF_ACM = "ietf-netconf-acm";
50 public void test_3gpp_extensions() {
52 parseAbsoluteImplementsYangModels(Arrays.asList(
53 "src/test/resources/model-statements-other/other-extension-test.yang", THREEGPP_YANG_EXT_PATH,
54 YANG_METADATA_PATH, NETCONF_ACM_PATH, "src/test/resources/_orig-modules/ietf-inet-types-2019-11-04.yang",
55 "src/test/resources/_orig-modules/ietf-yang-types-2019-11-04.yang"));
59 final YModule module = getModule("other-extension-test");
60 assertTrue(module != null);
62 final YIetfAnnotation annotation = getExtensionChild(module, IETF_YANG_METADATA, "annotation");
63 assertTrue(annotation != null);
64 assertTrue(annotation.getAnnotationName().equals("last-modified"));
65 assertTrue(getChild(annotation, "type") != null);
66 assertTrue(annotation.getStatementModuleAndName().equals(CIETF.IETF_YANG_METADATA__ANNOTATION));
68 final YContainer cont1 = getContainer(module, "cont1");
70 final YIetfDefaultDenyWrite defaultDenyWrite = getExtensionChild(cont1, IETF_NETCONF_ACM, "default-deny-write");
71 assertTrue(defaultDenyWrite != null);
72 assertTrue(defaultDenyWrite.getStatementModuleAndName().equals(CIETF.IETF_NETCONF_ACM__DEFAULT_DENY_WRITE));
74 final YLeaf leaf1 = getLeaf(cont1, "leaf1");
76 final Y3gppInVariant inVariant = getExtensionChild(leaf1, THREE_GPP_COMMON_YANG_EXTENSIONS, C3GPP.IN_VARIANT);
77 assertTrue(inVariant != null);
78 assertTrue(inVariant.getStatementModuleAndName().equals(C3GPP.THREEGPP_COMMON_YANG_EXTENSIONS__IN_VARIANT));
80 final Y3gppInitialValue threegppInitialValue = getExtensionChild(leaf1, THREE_GPP_COMMON_YANG_EXTENSIONS,
82 assertTrue(threegppInitialValue != null);
83 assertTrue(threegppInitialValue.getInitialValue().equals("Hello"));
84 assertTrue(threegppInitialValue.getStatementModuleAndName().equals(
85 C3GPP.THREEGPP_COMMON_YANG_EXTENSIONS__INITIAL_VALUE));
87 final Y3gppNotNotifyable threegppNotNotifyable = getExtensionChild(leaf1, THREE_GPP_COMMON_YANG_EXTENSIONS,
88 C3GPP.NOT_NOTIFYABLE);
89 assertTrue(threegppNotNotifyable != null);
90 assertNull(threegppNotNotifyable.getValue());
91 assertTrue(threegppNotNotifyable.getStatementModuleAndName().equals(
92 C3GPP.THREEGPP_COMMON_YANG_EXTENSIONS__NOT_NOTIFYABLE));
94 final YIetfDefaultDenyAll defaultDenyAll = getExtensionChild(leaf1, IETF_NETCONF_ACM, "default-deny-all");
95 assertTrue(defaultDenyAll != null);
96 assertTrue(defaultDenyAll.getStatementModuleAndName().equals(CIETF.IETF_NETCONF_ACM__DEFAULT_DENY_ALL));
100 public void test_CI_C3() {
101 assertTrue(CIETF.HANDLED_STATEMENTS.size() == 3);
102 assertTrue(CIETF.HANDLED_STATEMENTS.containsKey("ietf-yang-schema-mount"));
103 assertTrue(CIETF.HANDLED_STATEMENTS.containsKey("ietf-yang-metadata"));
104 assertTrue(CIETF.HANDLED_STATEMENTS.containsKey("ietf-netconf-acm"));
106 assertTrue(C3GPP.HANDLED_STATEMENTS.size() == 1);
107 assertTrue(C3GPP.HANDLED_STATEMENTS.containsKey("_3gpp-common-yang-extensions"));