Port yang-parser-rfc7950 to JUnit 5
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / EffectiveBuildTest.java
index bbe4fdec8d10145a51354cb987c00e6de2649bea..9d39f5d84def4433f6ad63f65671f1a274b02b84 100644 (file)
@@ -7,40 +7,35 @@
  */
 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.assertNotNull;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class EffectiveBuildTest {
+class EffectiveBuildTest {
 
     private static final StatementStreamSource SIMPLE_MODULE = sourceForResource(
-            "/stmt-test/effective-build/simple-module.yang");
+        "/stmt-test/effective-build/simple-module.yang");
     private static final QNameModule SIMPLE_MODULE_QNAME = QNameModule.create(XMLNamespace.of("simple.yang"));
     private static final StatementStreamSource YANG_EXT = sourceForResource(
-            "/stmt-test/extensions/yang-ext.yang");
+        "/stmt-test/extensions/yang-ext.yang");
 
     @Test
-    public void effectiveBuildTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSources(SIMPLE_MODULE)
-                .buildEffective();
+    void effectiveBuildTest() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild().addSources(SIMPLE_MODULE)
+            .buildEffective();
 
         assertNotNull(result);
 
@@ -89,28 +84,26 @@ public class EffectiveBuildTest {
     }
 
     @Test
-    public void extensionsTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
+    void extensionsTest() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
         assertNotNull(result);
 
-        Collection<? extends GroupingDefinition> groupings = result.getGroupings();
+        var groupings = result.getGroupings();
         assertEquals(1, groupings.size());
 
-        GroupingDefinition grp = groupings.iterator().next();
+        var grp = groupings.iterator().next();
 
-        Collection<? extends DataSchemaNode> childNodes = grp.getChildNodes();
+        var childNodes = grp.getChildNodes();
         assertEquals(1, childNodes.size());
-        DataSchemaNode child = childNodes.iterator().next();
 
-        assertTrue(child instanceof LeafSchemaNode);
-        LeafSchemaNode leaf = (LeafSchemaNode) child;
+        LeafSchemaNode leaf = assertInstanceOf(LeafSchemaNode.class, childNodes.iterator().next());
 
         assertNotNull(leaf.getType());
     }
 
     @Test
-    public void mockTest() throws ReactorException, FileNotFoundException, URISyntaxException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
+    void mockTest() throws Exception {
+        var result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
         assertNotNull(result);
     }
 }