2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.restconf.impl.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
15 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.Module;
18 public abstract class YangAndXmlAndDataSchemaLoader {
20 protected static Set<Module> modules;
21 protected static DataSchemaNode dataSchemaNode;
22 protected static String searchedModuleName;
23 protected static String searchedDataSchemaName;
24 protected static String schemaNodePath;
26 protected static void dataLoad(String yangPath) {
27 dataLoad(yangPath, 1, null, null);
30 protected static void dataLoad(String yangPath, int modulesNumber, String moduleName, String dataSchemaName) {
31 modules = TestUtils.loadModulesFrom(yangPath);
32 assertEquals(modulesNumber, modules.size());
33 Module module = TestUtils.resolveModule(moduleName, modules);
34 searchedModuleName = module == null ? "" : module.getName();
35 assertNotNull(module);
36 dataSchemaNode = TestUtils.resolveDataSchemaNode(dataSchemaName, module);
37 searchedDataSchemaName = dataSchemaNode == null ? "" : dataSchemaNode.getQName().getLocalName();
38 assertNotNull(dataSchemaNode);
39 schemaNodePath = searchedModuleName + ":" + searchedDataSchemaName;