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.test;
23 import static org.junit.Assert.assertTrue;
25 import java.util.Arrays;
26 import java.util.HashSet;
29 import org.junit.Test;
31 import org.oran.smo.yangtools.parser.findings.ParserFindingType;
32 import org.oran.smo.yangtools.parser.model.statements.yang.YCase;
33 import org.oran.smo.yangtools.parser.model.statements.yang.YChoice;
34 import org.oran.smo.yangtools.parser.model.statements.yang.YContainer;
35 import org.oran.smo.yangtools.parser.model.statements.yang.YLeaf;
36 import org.oran.smo.yangtools.parser.model.statements.yang.YModule;
37 import org.oran.smo.yangtools.parser.model.util.YangFeature;
38 import org.oran.smo.yangtools.parser.testutils.YangTestCommon;
40 public class UnsatisfiedIfFeatureRemoveTest extends YangTestCommon {
42 private static final String MODULE1 = "src/test/resources/basics/unsatisfied-if-feature-remove-test/module1.yang";
43 private static final String MODULE2 = "src/test/resources/basics/unsatisfied-if-feature-remove-test/module2.yang";
44 private static final String SUBMODULE3 = "src/test/resources/basics/unsatisfied-if-feature-remove-test/submodule3.yang";
47 public void test_module1_no_removal_no_supported_features() {
49 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
50 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
51 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
52 severityCalculator.suppressFinding(ParserFindingType.P143_ENUM_WITHOUT_VALUE.toString());
54 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
58 final YModule module = getModule("module1");
60 final YContainer cont1 = getContainer(module, "cont1");
61 assertTrue(cont1 != null);
63 final YLeaf leaf11 = getLeaf(cont1, "leaf11");
64 assertTrue(leaf11 != null);
66 final YLeaf leaf12 = getLeaf(cont1, "leaf12");
67 assertTrue(leaf12 != null);
69 final YLeaf leaf13 = getLeaf(cont1, "leaf13");
70 assertTrue(leaf13 != null);
72 final YLeaf leaf14 = getLeaf(cont1, "leaf14");
73 assertTrue(leaf14 != null);
77 public void test_module1_no_removal_with_supported_features() {
79 final Set<YangFeature> supportedFeatures = new HashSet<>();
80 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature11"));
81 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature12"));
82 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature13"));
83 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature14"));
85 context.setSupportedFeatures(supportedFeatures);
87 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
88 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
89 severityCalculator.suppressFinding(ParserFindingType.P143_ENUM_WITHOUT_VALUE.toString());
91 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
95 final YModule module = getModule("module1");
97 final YContainer cont1 = getContainer(module, "cont1");
98 assertTrue(cont1 != null);
100 final YLeaf leaf11 = getLeaf(cont1, "leaf11");
101 assertTrue(leaf11 != null);
103 final YLeaf leaf12 = getLeaf(cont1, "leaf12");
104 assertTrue(leaf12 != null);
106 final YLeaf leaf13 = getLeaf(cont1, "leaf13");
107 assertTrue(leaf13 != null);
109 final YLeaf leaf14 = getLeaf(cont1, "leaf14");
110 assertTrue(leaf14 != null);
114 public void test_module1_with_removal_no_supported_features() {
116 final Set<YangFeature> supportedFeatures = new HashSet<>();
117 context.setSupportedFeatures(supportedFeatures);
118 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
120 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
121 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
122 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
123 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
127 final YModule module = getModule("module1");
129 final YContainer cont1 = getContainer(module, "cont1");
130 assertTrue(cont1 != null);
132 assertTrue(getLeaf(cont1, "leaf11") == null);
133 assertTrue(getLeaf(cont1, "leaf12") == null);
134 assertTrue(getLeaf(cont1, "leaf13") == null);
135 assertTrue(getLeaf(cont1, "leaf14") == null);
137 final YContainer cont2 = getContainer(module, "cont2");
138 assertTrue(cont2 != null);
139 final YChoice choice21 = getChoice(cont2, "choice21");
140 assertTrue(choice21 != null);
142 assertTrue(getCase(choice21, "case211") == null);
143 assertTrue(getCase(choice21, "case212") == null);
144 assertTrue(getCase(choice21, "case213") == null);
145 assertTrue(getCase(choice21, "case214") == null);
146 assertTrue(getCase(choice21, "leaf215") == null);
148 final YContainer cont3 = getContainer(module, "cont3");
149 assertTrue(cont3 != null);
151 assertTrue(getLeaf(cont3, "leaf51") == null);
152 assertTrue(getLeaf(cont3, "leaf52") == null);
153 assertTrue(getLeaf(cont3, "leaf53") == null);
157 public void test_module1_with_removal_with_supported_features() {
159 final Set<YangFeature> supportedFeatures = new HashSet<>();
160 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature11"));
161 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature12"));
162 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature13"));
163 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature14"));
165 context.setSupportedFeatures(supportedFeatures);
166 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
168 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
169 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
170 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
171 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
175 final YModule module = getModule("module1");
177 final YContainer cont1 = getContainer(module, "cont1");
178 assertTrue(cont1 != null);
180 final YLeaf leaf11 = getLeaf(cont1, "leaf11");
181 assertTrue(leaf11 != null);
183 final YLeaf leaf12 = getLeaf(cont1, "leaf12");
184 assertTrue(leaf12 != null);
186 final YLeaf leaf13 = getLeaf(cont1, "leaf13");
187 assertTrue(leaf13 != null);
189 final YLeaf leaf14 = getLeaf(cont1, "leaf14");
190 assertTrue(leaf14 != null);
194 public void test_module1_with_removal_with_feature11_only() {
196 final Set<YangFeature> supportedFeatures = new HashSet<>();
197 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature11"));
199 context.setSupportedFeatures(supportedFeatures);
200 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
202 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
203 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
204 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
205 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
209 final YModule module = getModule("module1");
211 final YContainer cont1 = getContainer(module, "cont1");
212 assertTrue(cont1 != null);
214 final YLeaf leaf11 = getLeaf(cont1, "leaf11");
215 assertTrue(leaf11 != null);
217 final YLeaf leaf12 = getLeaf(cont1, "leaf12");
218 assertTrue(leaf12 == null);
220 final YLeaf leaf13 = getLeaf(cont1, "leaf13");
221 assertTrue(leaf13 != null);
223 final YLeaf leaf14 = getLeaf(cont1, "leaf14");
224 assertTrue(leaf14 == null);
228 public void test_module1_with_removal_with_feature11_and_feature12() {
230 final Set<YangFeature> supportedFeatures = new HashSet<>();
231 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature11"));
232 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature12"));
234 context.setSupportedFeatures(supportedFeatures);
235 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
237 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
238 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
239 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
240 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
244 final YModule module = getModule("module1");
246 final YContainer cont1 = getContainer(module, "cont1");
247 assertTrue(cont1 != null);
249 final YLeaf leaf11 = getLeaf(cont1, "leaf11");
250 assertTrue(leaf11 != null);
252 final YLeaf leaf12 = getLeaf(cont1, "leaf12");
253 assertTrue(leaf12 != null);
255 final YLeaf leaf13 = getLeaf(cont1, "leaf13");
256 assertTrue(leaf13 != null);
258 final YLeaf leaf14 = getLeaf(cont1, "leaf14");
259 assertTrue(leaf14 == null);
263 public void test_module1_with_removal_with_feature12_and_feature13() {
265 final Set<YangFeature> supportedFeatures = new HashSet<>();
266 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature12"));
267 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature13"));
269 context.setSupportedFeatures(supportedFeatures);
270 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
272 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
273 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
274 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
275 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
279 final YModule module = getModule("module1");
281 final YContainer cont1 = getContainer(module, "cont1");
282 assertTrue(cont1 != null);
284 final YLeaf leaf11 = getLeaf(cont1, "leaf11");
285 assertTrue(leaf11 == null);
287 final YLeaf leaf12 = getLeaf(cont1, "leaf12");
288 assertTrue(leaf12 != null);
290 final YLeaf leaf13 = getLeaf(cont1, "leaf13");
291 assertTrue(leaf13 != null);
293 final YLeaf leaf14 = getLeaf(cont1, "leaf14");
294 assertTrue(leaf14 == null);
298 public void test_module1_with_removal_with_feature13_and_feature14() {
300 final Set<YangFeature> supportedFeatures = new HashSet<>();
301 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature13"));
302 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature14"));
304 context.setSupportedFeatures(supportedFeatures);
305 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
307 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
308 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
309 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
310 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
312 final YModule module = getModule("module1");
315 * Should have resulted in a finding - feature 14 depends on 11 and 12, and these are not set.
318 assertStatementHasFindingOfType(getFeature(module, "feature14"), ParserFindingType.P086_FEATURE_CANNOT_BE_SUPPORTED
323 public void test_module1_with_removal_with_feature16() {
325 final Set<YangFeature> supportedFeatures = new HashSet<>();
326 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature16"));
328 context.setSupportedFeatures(supportedFeatures);
329 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
331 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
332 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
333 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
334 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
338 final YModule module = getModule("module1");
340 final YContainer cont2 = getContainer(module, "cont2");
341 assertTrue(cont2 != null);
343 final YChoice choice21 = getChoice(cont2, "choice21");
344 assertTrue(choice21 != null);
346 assertTrue(choice21.getCases().size() == 1);
348 final YCase case211 = getCase(choice21, "case211");
349 assertTrue(case211 != null);
350 assertTrue(getLeaf(case211, "leaf211") != null);
354 public void test_module1_with_removal_with_feature18_and_feature19() {
356 final Set<YangFeature> supportedFeatures = new HashSet<>();
357 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature18"));
358 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature19"));
360 context.setSupportedFeatures(supportedFeatures);
361 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
363 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
364 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
365 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
366 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
370 final YModule module = getModule("module1");
372 final YContainer cont2 = getContainer(module, "cont2");
373 assertTrue(cont2 != null);
375 final YChoice choice21 = getChoice(cont2, "choice21");
376 assertTrue(choice21 != null);
378 assertTrue(choice21.getCases().size() == 3);
380 final YCase case213 = getCase(choice21, "case213");
381 assertTrue(case213 != null);
382 assertTrue(getLeaf(case213, "leaf213") != null);
384 final YCase case214 = getCase(choice21, "case214");
385 assertTrue(case214 != null);
386 assertTrue(getLeaf(case214, "leaf214") != null);
388 final YCase case215 = getCase(choice21, "leaf215");
389 assertTrue(case215 != null);
390 assertTrue(getLeaf(case215, "leaf215") != null);
394 public void test_module1_with_removal_with_feature21() {
396 final Set<YangFeature> supportedFeatures = new HashSet<>();
397 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature21"));
399 context.setSupportedFeatures(supportedFeatures);
400 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
402 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
403 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
404 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
405 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
409 final YModule module = getModule("module1");
411 final YContainer cont3 = getContainer(module, "cont3");
412 assertTrue(cont3 != null);
414 assertTrue(getLeaf(cont3, "leaf51") == null);
415 assertTrue(getLeaf(cont3, "leaf52") == null);
416 assertTrue(getLeaf(cont3, "leaf53") == null);
420 public void test_module1_with_removal_with_feature23() {
422 final Set<YangFeature> supportedFeatures = new HashSet<>();
423 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature23"));
425 context.setSupportedFeatures(supportedFeatures);
426 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
428 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
429 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
430 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
431 severityCalculator.suppressFinding(ParserFindingType.P143_ENUM_WITHOUT_VALUE.toString());
433 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
437 final YModule module = getModule("module1");
439 final YContainer cont3 = getContainer(module, "cont3");
440 assertTrue(cont3 != null);
442 assertTrue(getLeaf(cont3, "leaf51") != null);
443 assertTrue(getLeaf(cont3, "leaf52") == null);
444 assertTrue(getLeaf(cont3, "leaf53") != null);
446 assertTrue(getLeaf(cont3, "leaf53").getType().getEnums().size() == 2);
450 public void test_module1_with_removal_with_feature21_and_feature23() {
452 final Set<YangFeature> supportedFeatures = new HashSet<>();
453 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature21"));
454 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature23"));
456 context.setSupportedFeatures(supportedFeatures);
457 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
459 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
460 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
461 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
462 severityCalculator.suppressFinding(ParserFindingType.P143_ENUM_WITHOUT_VALUE.toString());
464 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
468 final YModule module = getModule("module1");
470 final YContainer cont3 = getContainer(module, "cont3");
471 assertTrue(cont3 != null);
473 assertTrue(getLeaf(cont3, "leaf51") != null);
474 assertTrue(getLeaf(cont3, "leaf52") != null);
475 assertTrue(getLeaf(cont3, "leaf53") != null);
477 assertTrue(getLeaf(cont3, "leaf53").getType().getEnums().size() == 2);
481 public void test_module1_with_removal_with_feature22_and_feature23() {
483 final Set<YangFeature> supportedFeatures = new HashSet<>();
484 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature22"));
485 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature23"));
487 context.setSupportedFeatures(supportedFeatures);
488 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
490 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
491 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
492 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
493 severityCalculator.suppressFinding(ParserFindingType.P143_ENUM_WITHOUT_VALUE.toString());
495 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
499 final YModule module = getModule("module1");
501 final YContainer cont3 = getContainer(module, "cont3");
502 assertTrue(cont3 != null);
504 assertTrue(getLeaf(cont3, "leaf51") != null);
505 assertTrue(getLeaf(cont3, "leaf52") == null);
506 assertTrue(getLeaf(cont3, "leaf53") != null);
508 assertTrue(getLeaf(cont3, "leaf53").getType().getEnums().size() == 3);
512 public void test_module1_with_removal_with_feature31() {
514 final Set<YangFeature> supportedFeatures = new HashSet<>();
515 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature31"));
517 context.setSupportedFeatures(supportedFeatures);
518 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
520 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
521 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
522 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
523 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
527 final YModule module = getModule("module1");
529 final YContainer cont4 = getContainer(module, "cont4");
530 assertTrue(cont4 != null);
532 assertTrue(getLeaf(cont4, "leaf91") != null);
533 assertTrue(getLeaf(cont4, "leaf92") == null);
534 assertTrue(getLeaf(cont4, "leaf93") == null);
535 assertTrue(getLeaf(cont4, "leaf94") == null);
539 public void test_module1_with_removal_with_feature31_and_module2_feature11() {
541 final Set<YangFeature> supportedFeatures = new HashSet<>();
542 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature31"));
543 supportedFeatures.add(new YangFeature("urn:test:module2", "module2", "feature11")); // !!!!! module2 !!!!!
545 context.setSupportedFeatures(supportedFeatures);
546 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
548 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
549 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
550 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
551 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
555 final YModule module = getModule("module1");
557 final YContainer cont4 = getContainer(module, "cont4");
558 assertTrue(cont4 != null);
560 assertTrue(getLeaf(cont4, "leaf91") != null);
561 assertTrue(getLeaf(cont4, "leaf92") != null);
562 assertTrue(getLeaf(cont4, "leaf93") != null);
563 assertTrue(getLeaf(cont4, "leaf94") == null);
567 public void test_module1_with_removal_with_feature31_and_feature11_of_both_modules() {
569 final Set<YangFeature> supportedFeatures = new HashSet<>();
570 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature31"));
571 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature11"));
572 supportedFeatures.add(new YangFeature("urn:test:module2", "module2", "feature11")); // !!!!! module2 !!!!!
574 context.setSupportedFeatures(supportedFeatures);
575 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
577 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
578 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
579 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
580 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
584 final YModule module = getModule("module1");
586 final YContainer cont4 = getContainer(module, "cont4");
587 assertTrue(cont4 != null);
589 assertTrue(getLeaf(cont4, "leaf91") != null);
590 assertTrue(getLeaf(cont4, "leaf92") != null);
591 assertTrue(getLeaf(cont4, "leaf93") != null);
592 assertTrue(getLeaf(cont4, "leaf94") != null);
596 public void test_module1_with_removal_with_feature51() {
598 final Set<YangFeature> supportedFeatures = new HashSet<>();
599 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature51"));
601 context.setSupportedFeatures(supportedFeatures);
602 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
604 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
605 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
606 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
607 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
611 final YModule module = getModule("module1");
613 final YContainer cont5 = getContainer(module, "cont5");
614 assertTrue(cont5 != null);
616 assertTrue(getLeaf(cont5, "leaf51") != null);
617 assertTrue(getLeaf(cont5, "leaf52") == null);
618 assertTrue(getLeaf(cont5, "leaf53") == null);
622 public void test_module1_with_removal_with_feature52_and_feature58() {
624 final Set<YangFeature> supportedFeatures = new HashSet<>();
625 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature52"));
626 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature58"));
628 context.setSupportedFeatures(supportedFeatures);
629 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
631 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
632 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
633 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
634 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
638 final YModule module = getModule("module1");
640 final YContainer cont5 = getContainer(module, "cont5");
641 assertTrue(cont5 != null);
643 assertTrue(getLeaf(cont5, "leaf51") == null);
644 assertTrue(getLeaf(cont5, "leaf52") != null);
645 assertTrue(getLeaf(cont5, "leaf53") != null);
649 public void test_module1_with_removal_with_feature52() {
651 final Set<YangFeature> supportedFeatures = new HashSet<>();
652 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature52"));
654 context.setSupportedFeatures(supportedFeatures);
655 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
657 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
658 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
659 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
660 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
662 final YModule module = getModule("module1");
664 assertStatementHasFindingOfType(getFeature(module, "feature52"), ParserFindingType.P086_FEATURE_CANNOT_BE_SUPPORTED
669 public void test_module1_no_remove_thus_leaf61_does_exists() {
671 context.setRemoveSchemaNodesNotSatisfyingIfFeature(false); // !!!!!! FALSE !!!!!!
673 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
674 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
675 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
676 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
678 final YModule module = getModule("module1");
680 final YContainer cont6 = getContainer(module, "cont6");
681 assertTrue(cont6 != null);
682 assertTrue(getLeaf(cont6, "leaf61") != null);
686 public void test_module1_remove_thus_leaf61_not_exists() {
688 final Set<YangFeature> supportedFeatures = new HashSet<>();
689 context.setSupportedFeatures(supportedFeatures);
690 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
692 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
693 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
694 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
695 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
697 final YModule module = getModule("module1");
699 final YContainer cont6 = getContainer(module, "cont6");
700 assertTrue(cont6 != null);
701 assertTrue(getLeaf(cont6, "leaf61") == null);
705 public void test_module1_with_removal_with_feature71() {
707 final Set<YangFeature> supportedFeatures = new HashSet<>();
708 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature71"));
710 context.setSupportedFeatures(supportedFeatures);
711 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
713 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
714 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
715 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
716 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
720 final YModule module = getModule("module1");
722 final YContainer cont7 = getContainer(module, "cont7");
723 assertTrue(cont7 != null);
725 assertTrue(getLeaf(cont7, "leaf71") != null);
726 assertTrue(getLeaf(cont7, "leaf72") == null);
727 assertTrue(getLeaf(cont7, "leaf73") == null);
728 assertTrue(getLeaf(cont7, "leaf74") == null);
732 public void test_module1_with_removal_with_feature71_and_feature72() {
734 final Set<YangFeature> supportedFeatures = new HashSet<>();
735 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature71"));
736 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature72"));
738 context.setSupportedFeatures(supportedFeatures);
739 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
741 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
742 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
743 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
744 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
748 final YModule module = getModule("module1");
750 final YContainer cont7 = getContainer(module, "cont7");
751 assertTrue(cont7 != null);
753 assertTrue(getLeaf(cont7, "leaf71") == null);
754 assertTrue(getLeaf(cont7, "leaf72") == null);
755 assertTrue(getLeaf(cont7, "leaf73") == null);
756 assertTrue(getLeaf(cont7, "leaf74") == null);
760 public void test_module1_with_removal_with_feature71_and_feature72_and_feature73() {
762 final Set<YangFeature> supportedFeatures = new HashSet<>();
763 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature71"));
764 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature72"));
765 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature73"));
767 context.setSupportedFeatures(supportedFeatures);
768 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
770 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
771 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
772 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
773 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
777 final YModule module = getModule("module1");
779 final YContainer cont7 = getContainer(module, "cont7");
780 assertTrue(cont7 != null);
782 assertTrue(getLeaf(cont7, "leaf71") == null);
783 assertTrue(getLeaf(cont7, "leaf72") != null);
784 assertTrue(getLeaf(cont7, "leaf73") == null);
785 assertTrue(getLeaf(cont7, "leaf74") == null);
789 public void test_module1_with_removal_with_feature71_and_feature72_and_feature73_and_feature74() {
791 final Set<YangFeature> supportedFeatures = new HashSet<>();
792 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature71"));
793 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature72"));
794 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature73"));
795 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature74"));
797 context.setSupportedFeatures(supportedFeatures);
798 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
800 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
801 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
802 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
803 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
807 final YModule module = getModule("module1");
809 final YContainer cont7 = getContainer(module, "cont7");
810 assertTrue(cont7 != null);
812 assertTrue(getLeaf(cont7, "leaf71") == null);
813 assertTrue(getLeaf(cont7, "leaf72") != null);
814 assertTrue(getLeaf(cont7, "leaf73") != null);
815 assertTrue(getLeaf(cont7, "leaf74") == null);
819 public void test_module1_with_removal_with_feature71_and_feature73_and_feature75() {
821 final Set<YangFeature> supportedFeatures = new HashSet<>();
822 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature71"));
823 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature73"));
824 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature75"));
826 context.setSupportedFeatures(supportedFeatures);
827 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
829 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
830 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
831 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
832 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
836 final YModule module = getModule("module1");
838 final YContainer cont7 = getContainer(module, "cont7");
839 assertTrue(cont7 != null);
841 assertTrue(getLeaf(cont7, "leaf71") != null);
842 assertTrue(getLeaf(cont7, "leaf72") == null);
843 assertTrue(getLeaf(cont7, "leaf73") != null);
844 assertTrue(getLeaf(cont7, "leaf74") == null);
848 public void test_module1_with_removal_with_feature74() {
850 final Set<YangFeature> supportedFeatures = new HashSet<>();
851 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature74"));
853 context.setSupportedFeatures(supportedFeatures);
854 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
856 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
857 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
858 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
859 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
863 final YModule module = getModule("module1");
865 final YContainer cont7 = getContainer(module, "cont7");
866 assertTrue(cont7 != null);
868 assertTrue(getLeaf(cont7, "leaf71") == null);
869 assertTrue(getLeaf(cont7, "leaf72") == null);
870 assertTrue(getLeaf(cont7, "leaf73") == null);
871 assertTrue(getLeaf(cont7, "leaf74") != null);
875 public void test_module1_with_removal_with_feature74_and_feature76() {
877 final Set<YangFeature> supportedFeatures = new HashSet<>();
878 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature74"));
879 supportedFeatures.add(new YangFeature("urn:test:module1", "module1", "feature76"));
881 context.setSupportedFeatures(supportedFeatures);
882 context.setRemoveSchemaNodesNotSatisfyingIfFeature(true);
884 severityCalculator.suppressFinding(ParserFindingType.P103_ILLEGAL_IF_FEATURE_SYNTAX.toString());
885 severityCalculator.suppressFinding(ParserFindingType.P132_GROUPING_NOT_USED.toString());
886 severityCalculator.suppressFinding(ParserFindingType.P133_GROUPING_USED_ONCE_ONLY.toString());
887 parseAbsoluteImplementsYangModels(Arrays.asList(MODULE1, MODULE2, SUBMODULE3));
891 final YModule module = getModule("module1");
893 final YContainer cont7 = getContainer(module, "cont7");
894 assertTrue(cont7 != null);
896 assertTrue(getLeaf(cont7, "leaf71") == null);
897 assertTrue(getLeaf(cont7, "leaf72") == null);
898 assertTrue(getLeaf(cont7, "leaf73") == null);
899 assertTrue(getLeaf(cont7, "leaf74") == null);