Fix ReactorStmtCtx.calculateParentRefcount()
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / AbstractYangTest.java
index 4f389f691dd0fd723344138991c822bf371c910f..080f0b4db0a111675f0398e0e87e292dfc607b26 100644 (file)
@@ -7,15 +7,19 @@
  */
 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.assertThrows;
+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.junit.jupiter.api.Assertions.assertThrows;
 
 import com.google.common.base.Throwables;
+import java.util.List;
+import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.hamcrest.Matcher;
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.ri.type.InvalidBitDefinitionException;
 import org.opendaylight.yangtools.yang.model.ri.type.InvalidEnumDefinitionException;
@@ -28,11 +32,16 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
  * Abstract base class containing useful utilities and assertions.
  */
 public abstract class AbstractYangTest {
-    @SuppressWarnings("checkstyle:illegalCatch")
     public static @NonNull EffectiveModelContext assertEffectiveModel(final String... yangResourceName) {
+        return assertEffectiveModel(List.of(yangResourceName), null);
+    }
+
+    @SuppressWarnings("checkstyle:illegalCatch")
+    public static @NonNull EffectiveModelContext assertEffectiveModel(final List<String> yangResourceName,
+        final @Nullable Set<QName> supportedFeatures) {
         final EffectiveModelContext ret;
         try {
-            ret = TestUtils.parseYangSource(yangResourceName);
+            ret = TestUtils.parseYangSource(yangResourceName, supportedFeatures);
         } catch (Exception e) {
             Throwables.throwIfUnchecked(e);
             throw new AssertionError("Failed to assemble effective model", e);
@@ -41,11 +50,16 @@ public abstract class AbstractYangTest {
         return ret;
     }
 
-    @SuppressWarnings("checkstyle:illegalCatch")
     public static @NonNull EffectiveModelContext assertEffectiveModelDir(final String resourceDirName) {
+        return assertEffectiveModelDir(resourceDirName, null);
+    }
+
+    @SuppressWarnings("checkstyle:illegalCatch")
+    public static @NonNull EffectiveModelContext assertEffectiveModelDir(final String resourceDirName,
+            final @Nullable Set<QName> supportedFeatures) {
         final EffectiveModelContext ret;
         try {
-            ret = TestUtils.loadModules(resourceDirName);
+            ret = TestUtils.loadModules(resourceDirName, supportedFeatures);
         } catch (Exception e) {
             Throwables.throwIfUnchecked(e);
             throw new AssertionError("Failed to assemble effective model of " + resourceDirName, e);
@@ -59,8 +73,7 @@ public abstract class AbstractYangTest {
         final var ex = assertThrows(SomeModifiersUnresolvedException.class,
             () -> TestUtils.parseYangSource(yangResourceName));
         final var actual = ex.getCause();
-        assertThat(actual, instanceOf(cause));
-        return cause.cast(actual);
+        return assertInstanceOf(cause, actual);
     }
 
     public static <E extends SourceException> @NonNull E assertException(final Class<E> cause,
@@ -82,8 +95,7 @@ public abstract class AbstractYangTest {
         final var ex = assertThrows(SomeModifiersUnresolvedException.class,
             () -> TestUtils.loadModules(yangResourceName));
         final var actual = ex.getCause();
-        assertThat(actual, instanceOf(cause));
-        return cause.cast(actual);
+        return assertInstanceOf(cause, actual);
     }
 
     public static <E extends SourceException> @NonNull E assertExceptionDir(final String yangResourceName,