Replace calls of StmtTestUtils.parseYangSource(String)
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / IdentityStatementTest.java
index 8bce589e228d3e45822831f1ff51a5333be9eeb9..718e195def77d4a4eb8a8cd6777ffd58f608937d 100644 (file)
@@ -7,28 +7,23 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
+import static org.hamcrest.CoreMatchers.startsWith;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.Collection;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class IdentityStatementTest {
+public class IdentityStatementTest extends AbstractYangTest {
 
     @Test
-    public void testMultipleBaseIdentities() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/identity-stmt/foo.yang");
-        assertNotNull(schemaContext);
+    public void testMultipleBaseIdentities() {
+        final var context = assertEffectiveModel("/rfc7950/identity-stmt/foo.yang");
 
-        final Module foo = schemaContext.findModule("foo", Revision.of("2016-12-21")).get();
+        final Module foo = context.findModule("foo", Revision.of("2016-12-21")).get();
         for (final IdentitySchemaNode identity : foo.getIdentities()) {
             if ("derived-id".equals(identity.getQName().getLocalName())) {
                 final Collection<? extends IdentitySchemaNode> baseIdentities = identity.getBaseIdentities();
@@ -38,12 +33,8 @@ public class IdentityStatementTest {
     }
 
     @Test
-    public void testInvalidYang10() throws Exception {
-        try {
-            StmtTestUtils.parseYangSource("/rfc7950/identity-stmt/foo10.yang");
-            fail("Test should fail due to invalid Yang 1.0");
-        } catch (final ReactorException e) {
-            assertTrue(e.getCause().getMessage().startsWith("Maximal count of BASE for IDENTITY is 1, detected 3."));
-        }
+    public void testInvalidYang10() {
+        assertInvalidSubstatementException(startsWith("Maximal count of BASE for IDENTITY is 1, detected 3."),
+                "/rfc7950/identity-stmt/foo10.yang");
     }
 }