9192691f9fd6947ee2bcccaae617b36ae3fb7bfd
[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.Collection;
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     protected static Collection<? extends 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(final String yangPath) throws FileNotFoundException {
26         dataLoad(yangPath, 1, null, null);
27     }
28
29     protected static void dataLoad(final String yangPath, final int modulesNumber, final String moduleName,
30             final String dataSchemaName) throws FileNotFoundException {
31         modules = TestUtils.loadSchemaContext(yangPath).getModules();
32         assertEquals(modulesNumber, modules.size());
33         final 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;
40     }
41
42 }