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.model.api.ContainerSchemaNode;
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;
22 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
24 public class Bug9244Test {
27 public void testDeviateReplaceOfImplicitSubstatements() throws Exception {
28 final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9244/");
29 assertNotNull(schemaContext);
31 final Module barModule = schemaContext.findModule("bar", QName.parseRevision("2017-10-13")).get();
32 final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
33 QName.create(barModule.getQNameModule(), "bar-cont"));
34 assertNotNull(barCont);
35 assertFalse(barCont.isConfiguration());
37 final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
38 QName.create(barModule.getQNameModule(), "bar-leaf-list"));
39 assertNotNull(barLeafList);
40 assertEquals(5, barLeafList.getConstraints().getMinElements().intValue());
41 assertEquals(10, barLeafList.getConstraints().getMaxElements().intValue());
43 final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
44 QName.create(barModule.getQNameModule(), "bar-leaf"));
45 assertNotNull(barLeaf);
46 assertTrue(barLeaf.getConstraints().isMandatory());