1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
6 import java.io.IOException;
7 import java.util.regex.Matcher;
8 import java.util.regex.Pattern;
10 import javax.ws.rs.WebApplicationException;
13 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
14 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
15 import org.opendaylight.yangtools.yang.data.api.*;
16 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
18 public class ToJsonIdentityrefTest extends YangAndXmlAndDataSchemaLoader {
21 public static void initialization() {
22 dataLoad("/yang-to-json-conversion/identityref", 2, "identityref-module", "cont");
27 public void identityrefToJsonTest() {
31 .writeCompNodeWithSchemaContextToJson(prepareCompositeNode(), null, modules, dataSchemaNode);
32 } catch (WebApplicationException | IOException e) {
37 Pattern ptrn = Pattern.compile(".*\"lf1\"\\p{Space}*:\\p{Space}*\"identityref-module:name_test\".*",
39 Matcher mtch = ptrn.matcher(json);
41 assertTrue(mtch.matches());
44 private CompositeNode prepareCompositeNode() {
45 MutableCompositeNode cont = NodeFactory.createMutableCompositeNode(TestUtils.buildQName("cont"), null, null,
46 ModifyAction.CREATE, null);
47 MutableCompositeNode cont1 = NodeFactory.createMutableCompositeNode(TestUtils.buildQName("cont1"), cont, null,
48 ModifyAction.CREATE, null);
49 cont.getChildren().add(cont1);
51 MutableSimpleNode<?> lf1 = NodeFactory.createMutableSimpleNode(TestUtils.buildQName("lf1"), cont1,
52 TestUtils.buildQName("name_test", "identityref:module", "2013-12-2"), ModifyAction.CREATE, null);
53 cont1.getChildren().add(lf1);