ecce50b4ed4328ee7856118f43f9eae1fbefdb1c
[smo/teiv.git] /
1 /*
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
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21 package org.oran.smo.yangtools.parser.model.schema.test;
22
23 import static org.junit.Assert.assertTrue;
24
25 import java.util.Arrays;
26 import java.util.Collections;
27 import java.util.List;
28
29 import org.junit.Test;
30
31 import org.oran.smo.yangtools.parser.model.schema.AnnotationRegistry;
32 import org.oran.smo.yangtools.parser.model.util.YangAnnotation;
33 import org.oran.smo.yangtools.parser.testutils.YangTestCommon;
34
35 public class AnnotationRegistryTest extends YangTestCommon {
36
37     @Test
38     public void test_all_modules() {
39
40         final List<String> absoluteImplementsFilePath = Arrays.asList(
41                 "src/test/resources/model-schema/annotation-registry-test/module1.yang",
42                 "src/test/resources/model-schema/annotation-registry-test/module2.yang", YANG_METADATA_PATH,
43                 YANG_ORIGIN_PATH);
44         final List<String> absoluteImportsFilePath = Collections.<String> emptyList();
45
46         parseAbsoluteYangModels(absoluteImplementsFilePath, absoluteImportsFilePath);
47
48         assertNoFindings();
49
50         final AnnotationRegistry annotationRegistry = yangDeviceModel.getTopLevelSchema().getAnnotationRegistry();
51
52         final List<YangAnnotation> annotations = annotationRegistry.getAnnotations();
53
54         assertTrue(annotations.contains(new YangAnnotation("test:module1", "module1", "created")));
55         assertTrue(annotations.contains(new YangAnnotation("test:module1", "module1", "last-modified")));
56
57         assertTrue(annotations.contains(new YangAnnotation("test:module2", "module2", "modified-user")));
58
59         assertTrue(annotations.contains(new YangAnnotation("urn:ietf:params:xml:ns:yang:ietf-origin", "ietf-origin",
60                 "origin")));
61
62         assertTrue(annotations.size() == 4);
63     }
64
65 }