b1562b1433c9eca6a5af56d303e0f929897c9483
[netconf.git] / restconf / restconf-nb-bierman02 / 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.io.FileNotFoundException;
14 import java.util.Set;
15 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17
18 public abstract class YangAndXmlAndDataSchemaLoader {
19
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;
25
26     protected static void dataLoad(final String yangPath) throws FileNotFoundException {
27         dataLoad(yangPath, 1, null, null);
28     }
29
30     protected static void dataLoad(final String yangPath, final int modulesNumber, final String moduleName,
31             final String dataSchemaName) throws FileNotFoundException {
32         modules = TestUtils.loadSchemaContext(yangPath).getModules();
33         assertEquals(modulesNumber, modules.size());
34         final Module module = TestUtils.resolveModule(moduleName, modules);
35         searchedModuleName = module == null ? "" : module.getName();
36         assertNotNull(module);
37         dataSchemaNode = TestUtils.resolveDataSchemaNode(dataSchemaName, module);
38         searchedDataSchemaName = dataSchemaNode == null ? "" : dataSchemaNode.getQName().getLocalName();
39         assertNotNull(dataSchemaNode);
40         schemaNodePath = searchedModuleName + ":" + searchedDataSchemaName;
41     }
42
43 }