Instance identifier support
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / cnsn / to / xml / test / CnSnInstanceIdentifierToXmlTest.java
1 package org.opendaylight.controller.sal.restconf.impl.cnsn.to.xml.test;
2
3 import static org.junit.Assert.assertNotNull;
4
5 import java.io.IOException;
6 import java.net.URI;
7 import java.net.URISyntaxException;
8
9 import javax.ws.rs.WebApplicationException;
10
11 import org.junit.BeforeClass;
12 import org.junit.Test;
13 import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
14 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
15 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
16 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
17 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
18 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
19
20 /**
21  * 
22  * CnSn = Composite node and Simple node data structure Class contains test of
23  * serializing simple nodes data values according data types from YANG schema to
24  * XML file
25  * 
26  */
27 public class CnSnInstanceIdentifierToXmlTest extends YangAndXmlAndDataSchemaLoader {
28     
29     @BeforeClass
30     public static void initialization() throws URISyntaxException {
31         dataLoad("/instanceidentifier/yang", 3, "instance-identifier-module", "cont");
32     }
33
34     @Test
35     public void snAsYangInstanceIdentifier() throws WebApplicationException, IOException, URISyntaxException {
36         CompositeNode cnSnData = prepareCnStructForYangData( );
37         String xmlOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(cnSnData, modules, dataSchemaNode,
38                 StructuredDataToXmlProvider.INSTANCE);
39         assertNotNull(xmlOutput);
40     }
41
42     private CompositeNode prepareCnStructForYangData() throws URISyntaxException {
43         CompositeNodeWrapper cont = new CompositeNodeWrapper(new URI("instance:identifier:module"), "cont");
44         CompositeNodeWrapper cont1 = new CompositeNodeWrapper(new URI("augment:module"), "cont1");
45         cont.addValue(cont1);
46         SimpleNodeWrapper lf11 = new SimpleNodeWrapper(new URI("augment:augment:module"), "lf11", "/cont/cont1/lf12");
47         SimpleNodeWrapper lf12 = new SimpleNodeWrapper(new URI("augment:augment:module"), "lf12", "lf12 value");
48         cont1.addValue(lf11);
49         cont1.addValue(lf12);
50         cont.unwrap();
51         return cont;
52     }
53
54 }