+ public static void prepareMockForRestconfBeforeNormalization(Set<Module> modules, DataSchemaNode dataSchemaNode,
+ RestconfImpl restconf) {
+ ControllerContext instance = ControllerContext.getInstance();
+ instance.setSchemas(TestUtils.loadSchemaContext(modules));
+ restconf.setControllerContext(ControllerContext.getInstance());
+
+ BrokerFacade mockedBrokerFacade = mock(BrokerFacade.class);
+ when(mockedBrokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class)))
+ .thenReturn(
+ new DummyFuture.Builder().rpcResult(
+ new DummyRpcResult.Builder<TransactionStatus>().result(TransactionStatus.COMMITED)
+ .build()).build());
+ restconf.setBroker(mockedBrokerFacade);
+ }
+
+ static CompositeNode loadCompositeNodeWithXmlTreeBuilder(String xmlDataPath) {
+ InputStream xmlStream = TestUtils.class.getResourceAsStream(xmlDataPath);
+ CompositeNode compositeNode = null;
+ try {
+ compositeNode = TestUtils.loadCompositeNodeWithXmlTreeBuilder(xmlStream);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ return compositeNode;
+
+
+
+ }
+
+
+ public static CompositeNode loadCompositeNodeWithXmlTreeBuilder(InputStream xmlInputStream) throws FileNotFoundException {
+ if (xmlInputStream == null) {
+ throw new IllegalArgumentException();
+ }
+ Node<?> dataTree;
+ try {
+ dataTree = XmlTreeBuilder.buildDataTree(xmlInputStream);
+ } catch (XMLStreamException e) {
+ logger.error("Error during building data tree from XML", e);
+ return null;
+ }
+ if (dataTree == null) {
+ logger.error("data tree is null");
+ return null;
+ }
+ if (dataTree instanceof SimpleNode) {
+ logger.error("RPC XML was resolved as SimpleNode");
+ return null;
+ }
+ return (CompositeNode) dataTree;
+ }
+