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.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
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 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25 public class Bug9244Test {
28 public void testDeviateReplaceOfImplicitSubstatements() throws Exception {
29 final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9244/");
30 assertNotNull(schemaContext);
32 final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
33 final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
34 QName.create(barModule.getQNameModule(), "bar-cont"));
35 assertNotNull(barCont);
36 assertFalse(barCont.isConfiguration());
38 final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
39 QName.create(barModule.getQNameModule(), "bar-leaf-list"));
40 assertNotNull(barLeafList);
41 final ElementCountConstraint constraint = barLeafList.getElementCountConstraint().get();
42 assertEquals((Object) 5, constraint.getMinElements());
43 assertEquals((Object) 10, constraint.getMaxElements());
45 final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
46 QName.create(barModule.getQNameModule(), "bar-leaf"));
47 assertNotNull(barLeaf);
48 assertTrue(barLeaf.isMandatory());