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
9 package org.opendaylight.yangtools.yang.stmt;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertTrue;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.Revision;
19 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
21 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
26 public class Bug9244Test {
29 public void testDeviateReplaceOfImplicitSubstatements() throws Exception {
30 final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9244/");
31 assertNotNull(schemaContext);
33 final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
34 final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
35 QName.create(barModule.getQNameModule(), "bar-cont"));
36 assertNotNull(barCont);
37 assertFalse(barCont.isConfiguration());
39 final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
40 QName.create(barModule.getQNameModule(), "bar-leaf-list"));
41 assertNotNull(barLeafList);
42 final ElementCountConstraint constraint = barLeafList.getElementCountConstraint().get();
43 assertEquals(5, constraint.getMinElements().intValue());
44 assertEquals(10, constraint.getMaxElements().intValue());
46 final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
47 QName.create(barModule.getQNameModule(), "bar-leaf"));
48 assertNotNull(barLeaf);
49 assertTrue(barLeaf.isMandatory());