Further cleanup of tests
[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.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.util.Optional;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.common.Revision;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
20 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23
24 public class Bug9244Test extends AbstractYangTest {
25     @Test
26     public void testDeviateReplaceOfImplicitSubstatements() {
27         final var schemaContext = assertEffectiveModelDir("/bugs/bug9244/");
28
29         final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
30         final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
31                 QName.create(barModule.getQNameModule(), "bar-cont"));
32         assertNotNull(barCont);
33         assertEquals(Optional.of(Boolean.FALSE), barCont.effectiveConfig());
34
35         final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
36                 QName.create(barModule.getQNameModule(), "bar-leaf-list"));
37         assertNotNull(barLeafList);
38         final ElementCountConstraint constraint = barLeafList.getElementCountConstraint().get();
39         assertEquals((Object) 5, constraint.getMinElements());
40         assertEquals((Object) 10, constraint.getMaxElements());
41
42         final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
43                 QName.create(barModule.getQNameModule(), "bar-leaf"));
44         assertNotNull(barLeaf);
45         assertTrue(barLeaf.isMandatory());
46     }
47 }