Port yang-parser-rfc7950 to JUnit 5
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug9244Test.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertTrue;
12
13 import java.util.Optional;
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.Revision;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
19 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.Module;
22
23 class Bug9244Test extends AbstractYangTest {
24     @Test
25     void testDeviateReplaceOfImplicitSubstatements() {
26         final var schemaContext = assertEffectiveModelDir("/bugs/bug9244/");
27
28         final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
29         final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
30             QName.create(barModule.getQNameModule(), "bar-cont"));
31         assertEquals(Optional.of(Boolean.FALSE), barCont.effectiveConfig());
32
33         final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
34             QName.create(barModule.getQNameModule(), "bar-leaf-list"));
35         final ElementCountConstraint constraint = barLeafList.getElementCountConstraint().get();
36         assertEquals(5, constraint.getMinElements());
37         assertEquals(10, constraint.getMaxElements());
38
39         final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
40             QName.create(barModule.getQNameModule(), "bar-leaf"));
41         assertTrue(barLeaf.isMandatory());
42     }
43 }