Replace calls of StmtTestUtils.parseYangSource(String)
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / Bug6880Test.java
index b5c502ab89f57784610707aae764aba4cf15e46c..9ca49d7dc8166af922fda8362fe85703aebcaeae 100644 (file)
@@ -11,27 +11,21 @@ import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Collection;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6880Test {
+public class Bug6880Test extends AbstractYangTest {
     @Test
-    public void valid10Test() throws Exception {
-        final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6880/foo.yang");
-        assertNotNull(schemaContext);
+    public void valid10Test() {
+        final var context = assertEffectiveModel("/rfc7950/bug6880/foo.yang");
 
-        final DataSchemaNode findDataSchemaNode = schemaContext.findDataTreeChild(QName.create("foo", "my-leaf-list"))
+        final DataSchemaNode findDataSchemaNode = context.findDataTreeChild(QName.create("foo", "my-leaf-list"))
             .orElse(null);
         assertThat(findDataSchemaNode, instanceOf(LeafListSchemaNode.class));
         final LeafListSchemaNode myLeafList = (LeafListSchemaNode) findDataSchemaNode;
@@ -43,10 +37,7 @@ public class Bug6880Test {
 
     @Test
     public void invalid10Test() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSource("/rfc7950/bug6880/invalid10.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("DEFAULT is not valid for LEAF_LIST"));
+        assertInvalidSubstatementException(startsWith("DEFAULT is not valid for LEAF_LIST"),
+                "/rfc7950/bug6880/invalid10.yang");
     }
 }
\ No newline at end of file