2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertTrue;
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;
23 class Bug9244Test extends AbstractYangTest {
25 void testDeviateReplaceOfImplicitSubstatements() {
26 final var schemaContext = assertEffectiveModelDir("/bugs/bug9244/");
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());
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());
39 final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
40 QName.create(barModule.getQNameModule(), "bar-leaf"));
41 assertTrue(barLeaf.isMandatory());