- 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;
-
-
-
+ static NormalizedNode<?,?> prepareNormalizedNodeWithIetfInterfacesInterfacesData() throws ParseException {
+ final String ietfInterfacesDate = "2013-07-04";
+ final String namespace = "urn:ietf:params:xml:ns:yang:ietf-interfaces";
+ final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> mapEntryNode = ImmutableMapEntryNodeBuilder.create();
+
+ final Map<String, Object> predicates = new HashMap<>();
+ predicates.put("name", "eth0");
+
+ mapEntryNode.withNodeIdentifier(getNodeIdentifierPredicate("interface", namespace, ietfInterfacesDate,
+ predicates));
+ mapEntryNode
+ .withChild(new ImmutableLeafNodeBuilder<String>()
+ .withNodeIdentifier(getNodeIdentifier("name", namespace, ietfInterfacesDate)).withValue("eth0")
+ .build());
+ mapEntryNode.withChild(new ImmutableLeafNodeBuilder<String>()
+ .withNodeIdentifier(getNodeIdentifier("type", namespace, ietfInterfacesDate))
+ .withValue("ethernetCsmacd").build());
+ mapEntryNode.withChild(new ImmutableLeafNodeBuilder<Boolean>()
+ .withNodeIdentifier(getNodeIdentifier("enabled", namespace, ietfInterfacesDate))
+ .withValue(Boolean.FALSE).build());
+ mapEntryNode.withChild(new ImmutableLeafNodeBuilder<String>()
+ .withNodeIdentifier(getNodeIdentifier("description", namespace, ietfInterfacesDate))
+ .withValue("some interface").build());
+
+ return mapEntryNode.build();