Further cleanup of tests 98/100398/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Apr 2022 01:36:34 +0000 (03:36 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Apr 2022 01:48:44 +0000 (03:48 +0200)
Convert more tests to use AbstractYangTest's assertions.

Change-Id: Ib6efc701ba59d3c5323b8e69cfb51a2d22700e53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
43 files changed:
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Bug5410Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug2872Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug3799Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4410Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4456Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4610Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5059Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5335Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5396Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5481Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5518Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5550Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5712Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5884Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5899Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5942Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6131Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6240Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6669Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7037Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7038Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8126Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug9005Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug9242Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug9244Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/CaseStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ControllerStmtParserTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/IdentityIssueIetfRoutingTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1039Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1042Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1133Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1201Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1262Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT841Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT956Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserIdentityTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/test/Bug5200Test.java

index 8e4903b041d3584f1185fe71f7eaf7999402184d..f53ae333655592293b1ad1485d0af9368ee11233 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.ImmutableList;
@@ -22,15 +21,14 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug5410Test {
+public class Bug5410Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
 
     @Test
-    public void testYangPattern() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5410");
-        assertNotNull(context);
+    public void testYangPattern() {
+        final var context = assertEffectiveModelDir("/bugs/bug5410");
 
         final PatternConstraint pattern = getPatternConstraintOf(context, "leaf-with-pattern");
 
index d0dffbf3323ded1c2d77824c7486dfa54f3f6e35..d9456ba09339e7aef2e8240f26391353312c02d3 100644 (file)
@@ -8,12 +8,9 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.anyOf;
-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.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import java.util.Optional;
@@ -26,14 +23,11 @@ import org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
-
-public class Bug6874Test {
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
+public class Bug6874Test extends AbstractYangTest {
     private static final StatementStreamSource ROOT_MODULE = sourceForResource(
         "/rfc7950/include-import-stmt-test/valid-11/root-module.yang");
     private static final StatementStreamSource CHILD_MODULE = sourceForResource(
@@ -44,9 +38,8 @@ public class Bug6874Test {
         "/rfc7950/include-import-stmt-test/valid-11/imported-module.yang");
 
     @Test
-    public void valid11Test() throws Exception {
-        final var schemaContext = StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/valid-11");
-        assertNotNull(schemaContext);
+    public void valid11Test() {
+        final var schemaContext = assertEffectiveModelDir("/rfc7950/include-import-stmt-test/valid-11");
 
         // Test for valid include statement
         final Module testModule = schemaContext.findModules("root-module").iterator().next();
@@ -62,20 +55,14 @@ public class Bug6874Test {
 
     @Test
     public void invalid10IncludeStmtTest() {
-        final var ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/invalid-include-10")).getCause();
-        assertThat(ex, instanceOf(InvalidSubstatementException.class));
-        assertThat(ex.getMessage(), anyOf(
+        assertInvalidSubstatementExceptionDir("/rfc7950/include-import-stmt-test/invalid-include-10", anyOf(
             startsWith("DESCRIPTION is not valid for INCLUDE"),
             startsWith("REFERENCE is not valid for INCLUDE")));
     }
 
     @Test
-    public void invalid10ImportStmtTest() throws Exception {
-        final var ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/invalid-import-10")).getCause();
-        assertThat(ex, instanceOf(InvalidSubstatementException.class));
-        assertThat(ex.getMessage(), anyOf(
+    public void invalid10ImportStmtTest() {
+        assertInvalidSubstatementExceptionDir("/rfc7950/include-import-stmt-test/invalid-import-10", anyOf(
             startsWith("DESCRIPTION is not valid for IMPORT"),
             startsWith("REFERENCE is not valid for IMPORT")));
     }
@@ -95,8 +82,7 @@ public class Bug6874Test {
             });
     }
 
-    @SuppressWarnings("rawtypes")
-    private static void verifyDescAndRef(final DeclaredStatement stmt) {
+    private static void verifyDescAndRef(final DeclaredStatement<?> stmt) {
         if (stmt instanceof DescriptionStatement) {
             assertEquals("Yang 1.1: Allow description and reference in include and import.",
                 ((DescriptionStatement) stmt).argument());
index eb770b252047ff321ced291cf5bc320e6b290072..12e46f3a42c966fc3c551ea06fcd38e3686591bd 100644 (file)
@@ -10,16 +10,12 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertThrows;
 
 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.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6876Test extends AbstractYangTest {
     @Test
@@ -33,11 +29,7 @@ public class Bug6876Test extends AbstractYangTest {
 
     @Test
     public void yang10Test() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/rfc7950/bug6876/yang10"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/rfc7950/bug6876/yang10", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
 
index 75303aa1effdc1b612a6431f5be893d4e3607a49..29d44c279e9d0466a6af9ab5c2fc6a2ecf5573f9 100644 (file)
@@ -8,7 +8,6 @@
 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 java.util.ArrayList;
@@ -20,16 +19,13 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 
-public class Bug2872Test {
-
+public class Bug2872Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug2872");
-        assertNotNull(schema);
+    public void test() {
+        final var schema = assertEffectiveModelDir("/bugs/bug2872");
 
         final QNameModule bug2872module = QNameModule.create(XMLNamespace.of("bug2872"), Revision.of("2016-06-08"));
         final QName foo = QName.create(bug2872module, "bar");
index f4137be82da56ea48dfec5fc9e86dddf051c1d7a..cbd0cf4c18b4b89bf831c37f209076ae1e1d5748 100644 (file)
@@ -17,15 +17,12 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 
-public class Bug3799Test {
-
+public class Bug3799Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug3799");
-        assertNotNull(schema);
+    public void test() {
+        final var schema = assertEffectiveModelDir("/bugs/bug3799");
 
         Collection<? extends Module> modules = schema.getModules();
         assertNotNull(modules);
index 5543b3f25177ce7f0a4451b57d8120f8c469ebb2..a5271be0c64cfda4e3aba2271e26db3819d5f329 100644 (file)
@@ -7,27 +7,21 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
 
-import com.google.common.base.Throwables;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-
-public class Bug4410Test {
 
+public class Bug4410Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        try {
-            StmtTestUtils.parseYangSources("/bugs/bug4410");
-            fail("SomeModifiersUnresolvedException should be thrown.");
-        } catch (SomeModifiersUnresolvedException e) {
-            Throwable rootCause = Throwables.getRootCause(e);
-            assertTrue(rootCause instanceof InferenceException);
-            final String message = rootCause.getMessage();
-            assertTrue(message.startsWith("Type [(foo)"));
-            assertTrue(message.contains("was not found"));
-        }
+    public void test() {
+        final var cause = assertInferenceExceptionDir("/bugs/bug4410",
+            startsWith("Yang model processing phase EFFECTIVE_MODEL failed [at ")).getCause();
+        assertThat(cause, instanceOf(InferenceException.class));
+        assertThat(cause.getMessage(), allOf(startsWith("Type [(foo)"), containsString("was not found")));
     }
 }
index 974c9ae80210ae43d72141ce6b0f1bd50a16f944..35017dc46d6d831820bbb6e0ce699d68d4c9858e 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.util.Collection;
@@ -17,14 +16,12 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class Bug4456Test {
+public class Bug4456Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug4456");
-        assertNotNull(schema);
+    public void test() {
+        final var schema = assertEffectiveModelDir("/bugs/bug4456");
 
         Set<Module> modules = (Set<Module>) schema.findModules(XMLNamespace.of("foo"));
         assertEquals(1, modules.size());
index e0c892228e0ee1912bd2cab659c1928f925f84b1..c757e41d931d3c2079d5a999be455113d0d51cff 100644 (file)
@@ -25,10 +25,10 @@ import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 
-public class Bug4610Test {
+public class Bug4610Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug4610");
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug4610");
         final Revision revision = Revision.of("2015-12-12");
 
         // Original
index a931e1b61ecc35d0b91b3721ef4c1793c66f929a..aa82f7bd95ce2d04d9df43ec895e7687cdf8d199 100644 (file)
@@ -7,15 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
-
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class Bug5059Test {
+public class Bug5059Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5059");
-        assertNotNull(context);
+    public void test() {
+        assertEffectiveModelDir("/bugs/bug5059");
     }
 }
index 297e96754edc48d937950bb5e4c6207b98d93fc7..c99ba06452560f29dcfddb8018c160523a73a729 100644 (file)
@@ -10,15 +10,12 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertThrows;
 
 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.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class Bug5335Test extends AbstractYangTest {
     private static final String FOO = "foo";
@@ -34,31 +31,19 @@ public class Bug5335Test extends AbstractYangTest {
 
     @Test
     public void incorrectTest1() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-1"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-1", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
 
     @Test
     public void incorrectTest2() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-2"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-2", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
 
     @Test
     public void incorrectTest3() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-2"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-3", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
 
index 87597f9c59d0529ff52897c77f0fef416d3f886f..2991b4cd4fbbf88796544004d2d402cc80210b00 100644 (file)
@@ -12,24 +12,21 @@ import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
 
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 
-public class Bug5396Test {
+public class Bug5396Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5396");
-        assertNotNull(context);
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug5396");
 
         QName root = QName.create("foo", "root");
         QName myLeaf2 = QName.create("foo", "my-leaf2");
index 062e2cd62b7123b7086cb68c2edfc59f6c63c0c0..6926d024fbffd33f1ed5673dd68dda608c612aa4 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Optional;
@@ -17,25 +18,23 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound;
 
-public class Bug5481Test {
+public class Bug5481Test extends AbstractYangTest {
     @Test
     public void test() throws Exception {
-        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5481");
-        assertNotNull(context);
-
+        final var context = assertEffectiveModelDir("/bugs/bug5481");
         ContainerSchemaNode topContainer = verifyTopContainer(context);
         verifyExtendedLeaf(topContainer);
     }
 
-    private static ContainerSchemaNode verifyTopContainer(final SchemaContext context) {
+    private static ContainerSchemaNode verifyTopContainer(final EffectiveModelContext context) {
         QName top = QName.create("http://example.com/module1", "2016-03-09", "top");
         DataSchemaNode dataChildByName = context.getDataChildByName(top);
-        assertTrue(dataChildByName instanceof ContainerSchemaNode);
+        assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
 
         ContainerSchemaNode topContainer = (ContainerSchemaNode) dataChildByName;
 
index 88c034f9c31a6f88862913276e462d6347f80ed2..c9eed5281c0e6ad09ff150f80216f29ad7ad5468 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 import java.util.Collection;
 import org.junit.Test;
@@ -17,16 +17,13 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class Bug5518Test {
+public class Bug5518Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5518");
-        assertNotNull(context);
-
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug5518");
         final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "root"));
-        assertTrue(dataChildByName instanceof ContainerSchemaNode);
+        assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
         final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
         final Collection<? extends MustDefinition> mustConstraints = root.getMustConstraints();
         assertEquals(1, mustConstraints.size());
index d29f8d2ed10a741f6533d5b9b4be1768a385e098..f6c28f9e1d79d4848bd5d71cb2be35588de445d9 100644 (file)
@@ -9,22 +9,19 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNotNull;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
-public class Bug5550Test {
+public class Bug5550Test extends AbstractYangTest {
     private static final String NS = "foo";
     private static final String REV = "2016-03-18";
 
     @Test
-    public void test() throws Exception {
-        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5550");
-        assertNotNull(context);
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug5550");
 
         QName root = QName.create(NS, REV, "root");
         QName containerInGrouping = QName.create(NS, REV, "container-in-grouping");
index 84578c794ab5a3e83e23a9c3c12a4bb886935a8a..a5c9bc054139a6478a185c192e1a00e3eaf59cce 100644 (file)
@@ -14,17 +14,12 @@ import static org.junit.Assert.assertNotNull;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-public class Bug5712Test {
-
+public class Bug5712Test extends AbstractYangTest {
     @Test
-    public void testTypedefWithNewStatementParser() throws Exception {
-        SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5712");
-        assertNotNull(schemaContext);
-
-        Module badModule = schemaContext.findModules("bad").iterator().next();
+    public void testTypedefWithNewStatementParser() {
+        final var badModule = assertEffectiveModelDir("/bugs/bug5712").findModules("bad").iterator().next();
         assertNotNull(badModule);
         checkThing2TypeDef(badModule);
     }
index 74d05dac60680bea179354dee8a0c934bf2c1660..e8e4157a14de32f7a5a909194c12129ae9376b9a 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertNotNull;
 
 import java.util.Iterator;
 import org.junit.Test;
@@ -21,16 +20,14 @@ import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class Bug5884Test {
+public class Bug5884Test extends AbstractYangTest {
     private static final String NS = "urn:yang.foo";
     private static final String REV = "2016-01-01";
 
     @Test
-    public void testBug5884() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5884");
-        assertNotNull(context);
+    public void testBug5884() {
+        final var context = assertEffectiveModelDir("/bugs/bug5884");
 
         final QName root = QName.create(NS, REV, "main-container");
         final QName choice = QName.create(NS, REV, "test-choice");
index a9bf847bdd03a6981393163b3f3af035d13cd9e9..b5522b2e4f6eecd3d0266da81bb9fd58dbbf378a 100644 (file)
@@ -5,19 +5,13 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
-
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public class Bug5899Test {
 
+public class Bug5899Test extends AbstractYangTest {
     @Test
-    public void testBug5899() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5899");
-        assertNotNull(schemaContext);
+    public void testBug5899() {
+        assertEffectiveModelDir("/bugs/bug5899");
     }
 }
\ No newline at end of file
index 43d93475543b356e2d2ad72e9aedbfd14768bba1..95af9388c87b3758f950ba56d8e84a8ad7302224 100644 (file)
@@ -8,7 +8,6 @@
 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 java.util.Collection;
@@ -17,16 +16,14 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class Bug5942Test {
+public class Bug5942Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5942");
-        assertNotNull(schemaContext);
+    public void test() {
+        final var schemaContext = assertEffectiveModelDir("/bugs/bug5942");
 
         final DataSchemaNode root = schemaContext.getDataChildByName(QName.create("foo", "2016-06-02", "root"));
         assertTrue(root instanceof ContainerSchemaNode);
index 6b9690b85af9bc55d81840c4a230b92e2d90eaf0..710ffae2296824847ae3d662ebd6d72a52b25792 100644 (file)
@@ -8,17 +8,13 @@
 
 package org.opendaylight.yangtools.yang.stmt;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertThrows;
+
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
-public class Bug6131Test {
-    @Test(expected = NullPointerException.class)
-    public void test() throws ReactorException, URISyntaxException, SourceException, IOException,
-            YangSyntaxErrorException {
-        StmtTestUtils.parseYangSources("/bugs/bug6131");
+public class Bug6131Test extends AbstractYangTest {
+    @Test
+    public void test() {
+        assertThrows(NullPointerException.class, () -> TestUtils.loadModules("/bugs/bug6131"));
     }
 }
\ No newline at end of file
index f44361f384a8770ac9d1cc52e62b0baf183e2639..dc590638a30112fdfdb1fca70f720c6760c86596 100644 (file)
@@ -12,15 +12,12 @@ 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 org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
 public class Bug6240Test extends AbstractYangTest {
     private static final String NS = "bar";
@@ -60,10 +57,7 @@ public class Bug6240Test extends AbstractYangTest {
 
     @Test
     public void testInvalidModels() {
-        final var ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug6240/incorrect"));
-        final var cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));
+        assertInferenceExceptionDir("/bugs/bug6240/incorrect",
+            startsWith("Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));
     }
 }
index f7ee7b77c9b487046d0c4e0330231ffbaf250283..88adedfb46ece215cae78dd9dfcda805a586c0b9 100644 (file)
@@ -8,7 +8,6 @@
 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.Assert.fail;
 
@@ -25,11 +24,10 @@ import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 
-public class Bug6316Test {
+public class Bug6316Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6316");
-        assertNotNull(context);
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug6316");
         verifyEnumTypedefinition(context);
         verifyBitsTypedefinition(context);
     }
index 51ee39dd54da656b6279fbda0376d1543d24eb20..197c5846934ec6e2d1a612875fde30cb46b6bdb6 100644 (file)
@@ -10,19 +10,14 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class Bug6669Test {
+public class Bug6669Test extends AbstractYangTest {
     private static final String REV = "2016-09-08";
     private static final String FOO_NS = "foo";
     private static final String BAR_NS = "bar";
@@ -34,57 +29,39 @@ public class Bug6669Test {
 
     @Test
     public void testInvalidAugment() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test1"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug6669/invalid/test1", startsWith(
             "An augment cannot add node 'm' because it is mandatory and in module different than target"));
     }
 
     @Test
     public void testInvalidAugment2() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test2"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug6669/invalid/test2", startsWith(
             "An augment cannot add node 'm' because it is mandatory and in module different than target"));
     }
 
     @Test
     public void testInvalidAugment3() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () ->  StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test3"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug6669/invalid/test3", startsWith(
             "An augment cannot add node 'l' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void testValidAugment() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test1");
-        assertNotNull(context);
-
+    public void testValidAugment() {
+        final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test1");
         final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, M).get();
         assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
     }
 
     @Test
-    public void testValidAugment2() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test2");
-        assertNotNull(context);
-
+    public void testValidAugment2() {
+        final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test2");
         final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2, M).get();
         assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
     }
 
     @Test
     public void testValidAugment3() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test3");
-        assertNotNull(context);
-
+        final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test3");
         final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2,
                 QName.create(BAR_NS, REV, "l")).get();
         assertThat(findDataSchemaNode, instanceOf(ListSchemaNode.class));
index 1b5a62d8a4462911bcf5d7984c011555d2b16d4d..309997d468e3367c3f63909435c260d4dbcaab7a 100644 (file)
@@ -19,20 +19,18 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class Bug7037Test {
+public class Bug7037Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
     private static final String BAR_NS = "bar";
 
     @Test
-    public void test() throws Exception {
-        final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug7037");
-        assertNotNull(context);
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug7037");
 
-        final Collection<? extends UnrecognizedStatement> unknownSchemaNodes = context.getModuleStatement(foo("foo"))
-            .getDeclared().declaredSubstatements(UnrecognizedStatement.class);
+        final var unknownSchemaNodes = context.getModuleStatement(foo("foo")) .getDeclared()
+            .declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(1, unknownSchemaNodes.size());
 
         final UnrecognizedStatement first = unknownSchemaNodes.iterator().next();
index 34294e62e733d23a301a92a3eb5511e5463b9181..d75cb90e37880f7ce468ac955535357c0c5da3e1 100644 (file)
@@ -9,10 +9,10 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 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.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -24,12 +24,11 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 
-public class Bug7038Test {
+public class Bug7038Test extends AbstractYangTest {
     @Test
-    public void unknownNodeTest() throws Exception {
-        final ModuleStatement bar = StmtTestUtils.parseYangSources("/bugs/bug7038")
+    public void unknownNodeTest() {
+        final ModuleStatement bar = assertEffectiveModelDir("/bugs/bug7038")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("bar"))).getDeclared();
         final UnrecognizedStatement decimal64 = bar.findFirstDeclaredSubstatement(UnrecognizedStatement.class)
             .orElseThrow();
@@ -39,7 +38,7 @@ public class Bug7038Test {
 
     @Test
     public void testYang11() throws Exception {
-        final ContainerSchemaNode root = (ContainerSchemaNode) StmtTestUtils.parseYangSources("/bugs/bug7038/yang11")
+        final ContainerSchemaNode root = (ContainerSchemaNode) assertEffectiveModelDir("/bugs/bug7038/yang11")
             .getDataChildByName(QName.create("foo", "root"));
         final TypeDefinition<?> typedef = ((LeafSchemaNode) root.getDataChildByName(QName.create("foo", "my-leafref")))
             .getType();
@@ -49,10 +48,7 @@ public class Bug7038Test {
 
     @Test
     public void testYang10() throws Exception {
-        try {
-            StmtTestUtils.parseYangSources("/bugs/bug7038/yang10");
-        } catch (final SomeModifiersUnresolvedException e) {
-            assertTrue(e.getCause().getMessage().startsWith("REQUIRE_INSTANCE is not valid for TYPE"));
-        }
+        assertInvalidSubstatementExceptionDir("/bugs/bug7038/yang10",
+            startsWith("REQUIRE_INSTANCE is not valid for TYPE"));
     }
 }
index 586baeda12f257ace36c9b27ea98ddfc2408e845..653d0f386c98898081233884ac1661e4eba5a47c 100644 (file)
@@ -11,7 +11,6 @@ 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.assertThrows;
 
 import java.util.Optional;
 import org.junit.Test;
@@ -19,17 +18,14 @@ 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.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class Bug8126Test {
+public class Bug8126Test extends AbstractYangTest {
     private static final XMLNamespace FOO_NS = XMLNamespace.of("foo");
     private static final XMLNamespace BAR_NS = XMLNamespace.of("bar");
 
     @Test
-    public void testValidAugments() throws Exception {
-        final ModuleEffectiveStatement fooModule = StmtTestUtils.parseYangSources("/bugs/bug8126/valid")
+    public void testValidAugments() {
+        final var fooModule = assertEffectiveModelDir("/bugs/bug8126/valid")
             .getModuleStatement(QNameModule.create(FOO_NS));
         assertThat(fooModule.findSchemaTreeNode(
             foo("root"), bar("my-container"), bar("my-choice"), bar("one"), bar("one"), bar("mandatory-leaf"))
@@ -45,31 +41,19 @@ public class Bug8126Test {
 
     @Test
     public void testAugmentMandatoryChoice() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug8126/inv-choice"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug8126/inv-choice", startsWith(
             "An augment cannot add node 'mandatory-choice' because it is mandatory and in module different than "));
     }
 
     @Test
     public void testAugmentMandatoryList() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug8126/inv-list"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug8126/inv-list", startsWith(
             "An augment cannot add node 'mandatory-list' because it is mandatory and in module different than "));
     }
 
     @Test
     public void testAugmentMandatoryContainer() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/bugs/bug8126/inv-cont"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
+        assertInferenceExceptionDir("/bugs/bug8126/inv-cont", startsWith(
             "An augment cannot add node 'mandatory-leaf-3' because it is mandatory and in module different than "));
     }
 
index 389ada9b369db3ce9b641142b76d8042c3f0dd06..40ca85b095f94555159f8aa350fd3b69f20888c2 100644 (file)
@@ -8,24 +8,18 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class Bug8597Test {
+public class Bug8597Test extends AbstractYangTest {
     @Test
     public void test() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8597");
-        assertNotNull(context);
-
-        final Module foo = context.findModule("foo").get();
-        for (final ModuleImport moduleImport : foo.getImports()) {
+        final var foo = assertEffectiveModelDir("/bugs/bug8597").findModule("foo").orElseThrow();
+        for (ModuleImport moduleImport : foo.getImports()) {
             switch (moduleImport.getModuleName()) {
                 case "bar":
                     assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
index c62daf64ba84fdee6354e9bf70b2fcea0d5f0de7..828722729bbd60fff90e472c586337cd3053bad2 100644 (file)
@@ -8,21 +8,18 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 import java.util.Collection;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 
-public class Bug9005Test {
+public class Bug9005Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug9005");
-        assertNotNull(context);
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug9005");
 
         final Module foo = context.findModule("foo", Revision.of("2017-07-07")).get();
 
index 8f75d76d9eab9275f699a0324814b640eddd136a..70d02905cfdcec13b91973009cf0d944e03fbcdb 100644 (file)
@@ -17,18 +17,16 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
 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.model.api.TypeDefinition;
 
-public class Bug9242Test {
+public class Bug9242Test extends AbstractYangTest {
     @Test
-    public void testDeviateReplaceWithUserDefinedTypes() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9242/");
-        assertNotNull(schemaContext);
+    public void testDeviateReplaceWithUserDefinedTypes() {
+        final var schemaContext = assertEffectiveModelDir("/bugs/bug9242/");
 
         final Revision revision = Revision.of("2017-10-13");
-        final Module rootModule = schemaContext.findModule("root-module", revision).get();
-        final Module impModule = schemaContext.findModule("imp-module", revision).get();
+        final Module rootModule = schemaContext.findModule("root-module", revision).orElseThrow();
+        final Module impModule = schemaContext.findModule("imp-module", revision).orElseThrow();
 
         TypeDefinition<?> deviatedMyLeafType = null;
         TypeDefinition<?> deviatedMyLeaf2Type = null;
index e4a81c1bc89421762c2f7b98d1b878ffcc87841a..5ba1b6c9823a99c0938c0a4267febd222db46d79 100644 (file)
@@ -20,14 +20,11 @@ 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 {
 
+public class Bug9244Test extends AbstractYangTest {
     @Test
-    public void testDeviateReplaceOfImplicitSubstatements() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9244/");
-        assertNotNull(schemaContext);
+    public 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(
index ee03318aa84d60b8ca7e51226c577b77661dace1..dcbe351e2e04cb10ea0e8baec33c1bee53ecf57b 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
+import static org.hamcrest.CoreMatchers.startsWith;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
 
 import java.util.Optional;
 import org.junit.Before;
@@ -22,15 +22,14 @@ import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 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;
 
-public class CaseStmtTest {
+public class CaseStmtTest extends AbstractYangTest {
     private static final Optional<Boolean> OPT_FALSE = Optional.of(Boolean.FALSE);
     private static final Optional<Boolean> OPT_TRUE = Optional.of(Boolean.TRUE);
 
-    private SchemaContext schema;
+    private EffectiveModelContext schema;
     private Module rootFoo;
     private Module rootBar;
     private QNameModule qnameFoo;
@@ -41,8 +40,8 @@ public class CaseStmtTest {
     private CaseSchemaNode tempChoice;
 
     @Before
-    public void setup() throws Exception {
-        schema = StmtTestUtils.parseYangSources("/case-test");
+    public void setup() {
+        schema = assertEffectiveModelDir("/case-test");
         Revision rev = Revision.of("2015-09-09");
         rootFoo = schema.findModule("foo", rev).get();
         rootBar = schema.findModule("bar", rev).get();
@@ -530,13 +529,13 @@ public class CaseStmtTest {
 
     @Test
     public void testInferenceExceptionChoice() {
-        assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice"));
+        assertInferenceExceptionDir("/case-test/case-test-exceptions/choice",
+            startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));
     }
 
     @Test
-    public void testInferenceExceptionCase() throws Exception {
-        assertThrows(ReactorException.class,
-            () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case"));
+    public void testInferenceExceptionCase() {
+        assertInferenceExceptionDir("/case-test/case-test-exceptions/case",
+            startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));
     }
 }
\ No newline at end of file
index 6c3f9a0da891cf824fc4c528436ee27ca4e6615f..b51b5b8472a06cc87de98a7fdb9edf94423efb85 100644 (file)
@@ -29,13 +29,10 @@ import org.opendaylight.yangtools.yang.model.api.stmt.RefineEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
 
-public class ControllerStmtParserTest {
-
+public class ControllerStmtParserTest extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/sal-broker-impl");
-        assertNotNull(context);
-
+    public void test() {
+        final var context = assertEffectiveModelDir("/sal-broker-impl");
         salDomBrokerImplModuleTest(context);
         configModuleTest(context);
     }
index 648f644f36a0158fbe20cba11bb558ed403befac..43aa2d77243d802269eef46783c775aa3c2ba683 100644 (file)
@@ -44,12 +44,10 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class DeviationResolutionTest {
-
+public class DeviationResolutionTest extends AbstractYangTest {
     @Test
     public void testDeviateNotSupported() throws Exception {
-        final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSources(
-                "/deviation-resolution-test/deviation-not-supported");
+        final var schemaContext = assertEffectiveModelDir("/deviation-resolution-test/deviation-not-supported");
         assertNotNull(schemaContext);
 
         final Module importedModule = schemaContext.findModule("imported", Revision.of("2017-01-20")).get();
index 5b4a4e2e04a9544a033ab08f642c3703ad1ce605..5849aa871a7d201cff8fd6a0e6a5e16334ee2b10 100644 (file)
@@ -7,15 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
-
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class IdentityIssueIetfRoutingTest {
+public class IdentityIssueIetfRoutingTest extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/identity-ietf-routing-test/");
-        assertNotNull(context);
+    public void test() {
+        assertEffectiveModelDir("/bugs/identity-ietf-routing-test/");
     }
 }
index 3a591ce650c905d2ad59182fd4cc1d2412068e92..1b037d94413f7f11cb24d67d14865a6507f22f94 100644 (file)
@@ -122,11 +122,6 @@ public final class StmtTestUtils {
         return parseYangSources(config, supportedFeatures, sources);
     }
 
-    public static EffectiveModelContext parseYangSources(final String yangSourcesDirectoryPath)
-            throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
-        return parseYangSources(yangSourcesDirectoryPath, YangParserConfiguration.DEFAULT);
-    }
-
     public static EffectiveModelContext parseYangSources(final String yangSourcesDirectoryPath,
             final YangParserConfiguration config) throws ReactorException, URISyntaxException, IOException,
             YangSyntaxErrorException {
index 15e88ad4c75083ce6e900c3565fac5343432e3f8..b134482b574b740bbbaf4683fd36c1e83bf36fba 100644 (file)
@@ -11,9 +11,9 @@ import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 
-public class YT1039Test {
+public class YT1039Test extends AbstractYangTest {
     @Test
-    public void testUsesRefineAnyxml() throws Exception {
-        assertEquals(2, StmtTestUtils.parseYangSources("/bugs/YT1039").getModuleStatements().size());
+    public void testUsesRefineAnyxml() {
+        assertEquals(2, assertEffectiveModelDir("/bugs/YT1039").getModuleStatements().size());
     }
 }
index ab26a16c43bd63459889bc18e5db8158d0a564a3..d657c4de3e5389df8e61714c4b41e01f9dbdceb2 100644 (file)
@@ -7,26 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
 import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.fail;
 
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
-public class YT1042Test {
+public class YT1042Test extends AbstractYangTest {
     @Test
-    public void testSubmoduleConflict() throws Exception {
-        try {
-            StmtTestUtils.parseYangSources("/bugs/YT1042");
-            fail("Sechema assembly should have failed");
-        } catch (ReactorException e) {
-            final Throwable cause = e.getCause();
-            assertThat(cause, isA(SourceException.class));
-            assertThat(cause.getMessage(),
-                startsWith("Cannot add data tree child with name (foo)foo, a conflicting child already exists"));
-        }
+    public void testSubmoduleConflict() {
+        assertSourceExceptionDir("/bugs/YT1042",
+            startsWith("Cannot add data tree child with name (foo)foo, a conflicting child already exists"));
     }
 }
index fcb664aa26072e0c6ff64a13d6eb10a0c0fce339..c71d10dfbb129061493624609506b135f88fc1d6 100644 (file)
@@ -18,7 +18,7 @@ import java.nio.charset.StandardCharsets;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
-public class YT1133Test {
+public class YT1133Test extends AbstractYangTest {
     @Test
     @SuppressWarnings("checkstyle:regexpSinglelineJava")
     public void testAugmentKeys() throws Exception {
@@ -28,7 +28,7 @@ public class YT1133Test {
 
         try (PrintStream out = new PrintStream(output, true, StandardCharsets.UTF_8)) {
             System.setOut(out);
-            ctx = StmtTestUtils.parseYangSources("/bugs/YT1133");
+            ctx = assertEffectiveModelDir("/bugs/YT1133");
         } finally {
             System.setOut(stdout);
         }
index 08f99382f0afed85401e5332434e075c35ba53a5..088e05a17d0df5a030a5b0956525a4e4495fa187 100644 (file)
@@ -20,13 +20,13 @@ import org.opendaylight.yangtools.yang.xpath.api.YangExpr;
 import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath.Relative;
 import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
 
-public class YT1201Test {
+public class YT1201Test extends AbstractYangTest {
     private static final QName FOO = QName.create("foo", "foo");
     private static final QName BAR = QName.create("foo", "bar");
 
     @Test
-    public void testWhenPrefixes() throws Exception {
-        final DataSchemaNode bar = StmtTestUtils.parseYangSources("/bugs/YT1201/").getDataChildByName(BAR);
+    public void testWhenPrefixes() {
+        final DataSchemaNode bar = assertEffectiveModelDir("/bugs/YT1201/").getDataChildByName(BAR);
         assertThat(bar, instanceOf(ContainerSchemaNode.class));
         final YangExpr when = ((ContainerSchemaNode) bar).getWhenCondition().get().getRootExpr();
         assertThat(when, instanceOf(Relative.class));
index e31079486a752b285f1db7d83f7721bfc5946c5d..e2a368bc3e4ab9b52331f81df2a6a3211496a166 100644 (file)
@@ -24,10 +24,10 @@ import org.opendaylight.yangtools.yang.model.api.stmt.OutputEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefNamespace;
 
-public class YT1262Test {
+public class YT1262Test extends AbstractYangTest {
     @Test
-    public void testTypedefNamespaces() throws Exception {
-        final var modelContext = StmtTestUtils.parseYangSources("/bugs/YT1262");
+    public void testTypedefNamespaces() {
+        final var modelContext = assertEffectiveModelDir("/bugs/YT1262");
         final var module = modelContext.getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
         assertTypedef(module, "fdef");
         assertTypedef(module, "sdef");
index fc73ebd0f1245d2877e9e70687ec7acd5c4e479c..a208d74c89b4b2d849b04687071c7405181b712b 100644 (file)
@@ -15,12 +15,12 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 
-public class YT841Test {
+public class YT841Test extends AbstractYangTest {
     private static final QName FOO = QName.create("foo", "2018-01-02", "foo");
 
     @Test
     public void testFindDataSchemaNode() throws Exception {
-        final SchemaTreeEffectiveStatement<?> input = StmtTestUtils.parseYangSources("/bugs/YT841/")
+        final SchemaTreeEffectiveStatement<?> input = assertEffectiveModelDir("/bugs/YT841/")
             .getModuleStatement(FOO)
             .findSchemaTreeNode(FOO, FOO, FOO, QName.create(FOO, "input"))
             .orElse(null);
index 7f2693c838f216738150948159909778c22d5425..19cf648685c3fe6fe57b9c6450b26af0c793c176 100644 (file)
@@ -16,15 +16,15 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
-public class YT956Test {
+public class YT956Test extends AbstractYangTest {
     private static final QName ANOTHER_CONTAINER = QName.create("http://www.example.com/anothermodule",
         "another-container");
     private static final QName FIRST_AUGMENT = QName.create("http://www.example.com/mainmodule", "first-augment");
 
     @Test
-    public void testAugmentationConditional() throws Exception {
-        final DataSchemaNode another = StmtTestUtils.parseYangSources("/bugs/YT956/")
-                .findDataChildByName(ANOTHER_CONTAINER).get();
+    public void testAugmentationConditional() {
+        final DataSchemaNode another = assertEffectiveModelDir("/bugs/YT956/")
+                .getDataChildByName(ANOTHER_CONTAINER);
         assertThat(another, isA(ContainerSchemaNode.class));
         final ContainerSchemaNode anotherContainer = (ContainerSchemaNode) another;
 
index d5b95791f9f550a0e37020a7c81bd287f94548c9..1bfa3555d491de70a7cfa16ca90f2af3731540ee 100644 (file)
@@ -11,9 +11,7 @@ import static org.hamcrest.CoreMatchers.startsWith;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 
-import java.util.Collection;
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
 public class YangParserIdentityTest extends AbstractYangTest {
@@ -35,10 +33,10 @@ public class YangParserIdentityTest extends AbstractYangTest {
     // imported module prefixed base identity name equals identity name, but
     // prefix differs
     @Test
-    public void testParsingImportPrefixIdentityTestModule() throws Exception {
-        Module module = StmtTestUtils.parseYangSources("/identity/import").findModules("prefiximportidentitytest")
+    public void testParsingImportPrefixIdentityTestModule() {
+        final var module = assertEffectiveModelDir("/identity/import").findModules("prefiximportidentitytest")
             .iterator().next();
-        Collection<? extends ModuleImport> imports = module.getImports();
+        final var imports = module.getImports();
         assertEquals(imports.size(), 1);
         ModuleImport dummy = TestUtils.findImport(imports, "dummy");
         assertNotEquals(dummy.getPrefix(), module.getPrefix());
index 2b42c6b9bcf632549c5271da2dd69e5639f272f6..f2f13907c68f4aa443ab033d768e6032f031bdf5 100644 (file)
@@ -10,14 +10,12 @@ package org.opendaylight.yangtools.yang.stmt.test;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 import java.util.List;
 import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
@@ -25,16 +23,15 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug5200Test {
+public class Bug5200Test extends AbstractYangTest {
     private static final String NS = "foo";
     private static final String REV = "2016-05-05";
 
     @Test
-    public void test() throws Exception {
-        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5200");
-        assertNotNull(context);
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug5200");
 
         QName root = QName.create(NS, REV, "root");
         QName myLeaf = QName.create(NS, REV, "my-leaf");