+ private void simpleTest(String jsonPath, String yangPath, String topLevelElementName, String namespace) {
+ CompositeNode compositeNode = compositeContainerFromJson(jsonPath);
+ assertNotNull(compositeNode);
+
+ DataSchemaNode dataSchemaNode = obtainSchemaFromYang(yangPath);
+ assertNotNull(dataSchemaNode);
+
+ supplementNamespace(dataSchemaNode, compositeNode);
+
+ assertTrue(compositeNode instanceof CompositeNodeWrapper);
+ CompositeNode compNode = ((CompositeNodeWrapper) compositeNode).unwrap(null);
+
+ assertEquals(topLevelElementName, compNode.getNodeType().getLocalName());
+ verifyCompositeNode(compNode, namespace);
+ }
+
+ private DataSchemaNode obtainSchemaFromYang(String yangFolder) {
+ Set<Module> modules = null;
+ try {
+ modules = TestUtils.loadModules(ToJsonBasicDataTypesTest.class.getResource(yangFolder).getPath());
+ } catch (FileNotFoundException e) {
+ LOG.error(e.getMessage());
+ assertTrue(false);
+ }
+
+ assertNotNull(modules);
+ assertEquals(1, modules.size());
+ Module module = modules.iterator().next();
+ assertNotNull(module.getChildNodes());
+ assertEquals(1, module.getChildNodes().size());
+ DataSchemaNode dataSchemaNode = module.getChildNodes().iterator().next();
+ return dataSchemaNode;
+ }
+
+ private void supplementNamespace(DataSchemaNode dataSchemaNode, CompositeNode compositeNode) {
+ RestconfImpl restconf = RestconfImpl.getInstance();
+
+ InstanceIdWithSchemaNode instIdAndSchema = new InstanceIdWithSchemaNode(mock(InstanceIdentifier.class),
+ dataSchemaNode);
+
+ ControllerContext controllerContext = mock(ControllerContext.class);
+ BrokerFacade broker = mock(BrokerFacade.class);
+
+ when(controllerContext.toInstanceIdentifier(any(String.class))).thenReturn(instIdAndSchema);
+ when(broker.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(
+ new DummyFuture());
+
+ restconf.setControllerContext(controllerContext);
+ restconf.setBroker(broker);
+
+ // method is called only because it contains call of method which
+ // supplement namespaces to compositeNode
+ restconf.createConfigurationData("something", compositeNode);
+ }
+