Introduce yangtools.binding.meta
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / ChoiceStmtTest.java
index a91c52c871e68fb026c9bfee462c43cfe1c972a9..df7fbd4a11ef3ad3b00d6143a371e6da9c84608f 100644 (file)
@@ -7,40 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+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 java.io.IOException;
-import java.net.URISyntaxException;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class ChoiceStmtTest {
+class ChoiceStmtTest extends AbstractModelTest {
     @Test
-    public void choiceAndCaseTest() throws ReactorException, YangSyntaxErrorException, URISyntaxException, IOException {
-        final SchemaContext result = StmtTestUtils.parseYangSources("/model");
-        assertNotNull(result);
-
-        final Module testModule = result.findModules("foo").iterator().next();
-        assertNotNull(testModule);
-
-        final ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "transfer"));
-        assertNotNull(container);
-
-        final ChoiceSchemaNode choice = (ChoiceSchemaNode) container.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "how"));
-        assertNotNull(choice);
+    void choiceAndCaseTest() {
+        final var container = assertInstanceOf(ContainerSchemaNode.class, FOO.getDataChildByName(fooQName("transfer")));
+        final var choice = assertInstanceOf(ChoiceSchemaNode.class, container.getDataChildByName(fooQName("how")));
         assertEquals(5, choice.getCases().size());
 
-        CaseSchemaNode caseNode = choice.findCaseNodes("input").iterator().next();
+        var caseNode = choice.findCaseNodes("input").iterator().next();
         assertNotNull(caseNode);
         caseNode = choice.findCaseNodes("output").iterator().next();
         assertNotNull(caseNode);
@@ -50,6 +32,6 @@ public class ChoiceStmtTest {
         assertNotNull(caseNode);
         caseNode = choice.findCaseNodes("manual").iterator().next();
         assertNotNull(caseNode);
-        assertEquals("interval", choice.getDefaultCase().get().getQName().getLocalName());
+        assertEquals("interval", choice.getDefaultCase().orElseThrow().getQName().getLocalName());
     }
 }