Introduce yangtools.binding.meta
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug9244Test.java
index e4a81c1bc89421762c2f7b98d1b878ffcc87841a..115c29274eb335cb5a51c138d61e22e8cc987f46 100644 (file)
@@ -7,44 +7,36 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public class Bug9244Test {
 
+class Bug9244Test extends AbstractYangTest {
     @Test
-    public void testDeviateReplaceOfImplicitSubstatements() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9244/");
-        assertNotNull(schemaContext);
+    void testDeviateReplaceOfImplicitSubstatements() {
+        final var schemaContext = assertEffectiveModelDir("/bugs/bug9244/");
 
-        final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
-        final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "bar-cont"));
-        assertNotNull(barCont);
+        final var barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).orElseThrow();
+        final var barCont = assertInstanceOf(ContainerSchemaNode.class,
+            barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "bar-cont")));
         assertEquals(Optional.of(Boolean.FALSE), barCont.effectiveConfig());
 
-        final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "bar-leaf-list"));
-        assertNotNull(barLeafList);
-        final ElementCountConstraint constraint = barLeafList.getElementCountConstraint().get();
-        assertEquals((Object) 5, constraint.getMinElements());
-        assertEquals((Object) 10, constraint.getMaxElements());
+        final var barLeafList = assertInstanceOf(LeafListSchemaNode.class,
+            barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "bar-leaf-list")));
+        final var constraint = barLeafList.getElementCountConstraint().orElseThrow();
+        assertEquals(5, constraint.getMinElements());
+        assertEquals(10, constraint.getMaxElements());
 
-        final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "bar-leaf"));
-        assertNotNull(barLeaf);
+        final var barLeaf = assertInstanceOf(LeafSchemaNode.class,
+            barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "bar-leaf")));
         assertTrue(barLeaf.isMandatory());
     }
 }