Merge "Bug 1125: Added regression test"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / YangAndXmlAndDataSchemaLoader.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.restconf.impl.test;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.util.Set;
14 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16
17 public abstract class YangAndXmlAndDataSchemaLoader {
18
19     protected static Set<Module> modules;
20     protected static DataSchemaNode dataSchemaNode;
21     protected static String searchedModuleName;
22     protected static String searchedDataSchemaName;
23     protected static String schemaNodePath;
24
25     protected static void dataLoad(String yangPath) {
26         dataLoad(yangPath, 1, null, null);
27     }
28
29     protected static void dataLoad(String yangPath, int modulesNumber, String moduleName, String dataSchemaName) {
30         modules = TestUtils.loadModulesFrom(yangPath);
31         assertEquals(modulesNumber, modules.size());
32         Module module = TestUtils.resolveModule(moduleName, modules);
33         searchedModuleName = module == null ? "" : module.getName();
34         assertNotNull(module);
35         dataSchemaNode = TestUtils.resolveDataSchemaNode(dataSchemaName, module);
36         searchedDataSchemaName = dataSchemaNode == null ? "" : dataSchemaNode.getQName().getLocalName();
37         assertNotNull(dataSchemaNode);
38         schemaNodePath = searchedModuleName + ":" + searchedDataSchemaName;
39     }
40
41 }