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.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
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;
24 public class Bug9244Test extends AbstractYangTest {
26 public void testDeviateReplaceOfImplicitSubstatements() {
27 final var schemaContext = assertEffectiveModelDir("/bugs/bug9244/");
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());
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());
42 final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
43 QName.create(barModule.getQNameModule(), "bar-leaf"));
44 assertNotNull(barLeaf);
45 assertTrue(barLeaf.isMandatory());