Common yang and xml loader for tests
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / YangAndXmlAndDataSchemaLoader.java
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlAndDataSchemaLoader.java
new file mode 100644 (file)
index 0000000..7e3da0e
--- /dev/null
@@ -0,0 +1,27 @@
+package org.opendaylight.controller.sal.restconf.impl.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.*;
+
+public abstract class YangAndXmlAndDataSchemaLoader {
+
+    protected static Set<Module> modules;
+    protected static DataSchemaNode dataSchemaNode;
+
+    protected static void dataLoad(String yangPath) {
+        dataLoad(yangPath, 1, null, null);
+    }
+
+    protected static void dataLoad(String yangPath, int modulesNumber, String moduleName, String dataSchemaName) {
+        modules = TestUtils.resolveModules(yangPath);
+        assertEquals(modulesNumber, modules.size());
+        Module module = TestUtils.resolveModule(moduleName, modules);
+        assertNotNull(module);
+        dataSchemaNode = TestUtils.resolveDataSchemaNode(module, dataSchemaName);
+        assertNotNull(dataSchemaNode);
+    }
+
+}