*/
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;
* 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);
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);
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,
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,