+ public static String convertCompositeNodeDataAndYangToJson(CompositeNode compositeNode, String yangPath,
+ String outputPath, String searchedModuleName, String searchedDataSchemaName) {
+ Set<Module> modules = resolveModules(yangPath);
+ Module module = resolveModule(searchedModuleName, modules);
+ DataSchemaNode dataSchemaNode = resolveDataSchemaNode(module, searchedDataSchemaName);
+
+ normalizeCompositeNode(compositeNode, modules, dataSchemaNode, searchedModuleName + ":"
+ + searchedDataSchemaName);
+
+ try {
+ return writeCompNodeWithSchemaContextToJson(compositeNode, modules, dataSchemaNode);
+ } catch (WebApplicationException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+
+ }
+
+ public static void normalizeCompositeNode(CompositeNode compositeNode, Set<Module> modules,
+ DataSchemaNode dataSchemaNode, String schemaNodePath) {
+ RestconfImpl restconf = RestconfImpl.getInstance();
+ ControllerContext.getInstance().setSchemas(TestUtils.loadSchemaContext(modules));
+
+ TestUtils.prepareMockForRestconfBeforeNormalization(modules, dataSchemaNode, restconf);
+ restconf.createConfigurationData(schemaNodePath, compositeNode);
+ }
+
+ public static Module resolveModule(String searchedModuleName, Set<Module> modules) {
+ assertNotNull("modules can't be null.", modules);
+ Module module = null;
+ if (searchedModuleName != null) {
+ for (Module m : modules) {
+ if (m.getName().equals(searchedModuleName)) {
+ module = m;
+ break;
+ }
+ }
+ } else if (modules.size() == 1) {
+ module = modules.iterator().next();
+ }
+ return module;
+ }
+
+ public static Set<Module> resolveModules(String yangPath) {