- @Test
- public void testNullInputXmlToComposite() {
- CompositeNode node = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), null, schema);
- Assert.assertNull(node);
- }
-
- @Test
- public void testNullRpcXmlToComposite() {
- CompositeNode node = XmlUtils.inputXmlToCompositeNode(null, XML_CONTENT, schema);
- Assert.assertNull(node);
- }
-
- @Test
- public void testInputXmlToCompositeNode() {
- CompositeNode node = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), XML_CONTENT, schema);
- ImmutableList<SimpleNode> input = (ImmutableList)node.getValue().get(0).getValue();
- SimpleNode firstNode = input.get(0);
-
- Assert.assertEquals("id", firstNode.getNodeType().getLocalName());
- Assert.assertEquals("flowid", firstNode.getValue());
-
- SimpleNode secondNode = input.get(1);
- Assert.assertEquals("flow", secondNode.getNodeType().getLocalName());
-
- YangInstanceIdentifier instance = (YangInstanceIdentifier) secondNode.getValue();
- Iterable<YangInstanceIdentifier.PathArgument> iterable = instance.getPathArguments();
- Iterator it = iterable.iterator();
- YangInstanceIdentifier.NodeIdentifier firstPath = (YangInstanceIdentifier.NodeIdentifier) it.next();
- Assert.assertEquals("node", firstPath.getNodeType().getLocalName());
- YangInstanceIdentifier.NodeIdentifierWithPredicates secondPath = (YangInstanceIdentifier.NodeIdentifierWithPredicates)it.next();
- Short value = (Short)secondPath.getKeyValues().values().iterator().next();
- Short expected = 3;
- Assert.assertEquals(expected, value);
- }
-
- @Test
- public void testInputCompositeNodeToXML() {
- CompositeNode input = XmlUtils.inputXmlToCompositeNode(testRpc.getQName(), XML_CONTENT, schema);
- List<Node<?>> childNodes = new ArrayList();
- childNodes.add(input);
- QName rpcQName = schema.getOperations().iterator().next().getQName();
- CompositeNode node = new ImmutableCompositeNode(rpcQName, input.getValue(), ModifyAction.REPLACE);
- String xml = XmlUtils.inputCompositeNodeToXml(node, schema);
- Assert.assertNotNull(xml);
- Assert.assertTrue(xml.contains("3@java.lang.Short"));
- }
-
- @Test
- public void testNullCompositeNodeToXml(){
- String xml = XmlUtils.inputCompositeNodeToXml(null, schema);
- Assert.assertTrue(xml.isEmpty());
- }
-
- @Test
- public void testNullSchemaCompositeNodeToXml(){
- String xml = XmlUtils.inputCompositeNodeToXml(new ImmutableCompositeNode(QName.create("ns", "2013-12-09", "child1"), new ArrayList<Node<?>>(), ModifyAction.REPLACE), null);
- Assert.assertTrue(xml.isEmpty());
- }
-
-