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.*;
9 import javax.ws.rs.WebApplicationException;
12 import org.opendaylight.yangtools.yang.data.api.*;
13 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
15 public class ToJsonIdentityrefTest extends YangAndXmlAndDataSchemaLoader {
18 public static void initialization() {
19 dataLoad("/yang-to-json-conversion/identityref", 2, "identityref-module", "cont");
23 public void identityrefToJsonTest() {
27 .writeCompNodeWithSchemaContextToJson(prepareCompositeNode(), null, modules, dataSchemaNode);
28 } catch (WebApplicationException | IOException e) {
33 Pattern ptrn = Pattern.compile(".*\"lf1\"\\p{Space}*:\\p{Space}*\"identityref-module:name_test\".*",
35 Matcher mtch = ptrn.matcher(json);
37 assertTrue(mtch.matches());
40 private CompositeNode prepareCompositeNode() {
41 MutableCompositeNode cont = NodeFactory.createMutableCompositeNode(TestUtils.buildQName("cont"), null, null,
42 ModifyAction.CREATE, null);
43 MutableSimpleNode<?> lf1 = NodeFactory.createMutableSimpleNode(TestUtils.buildQName("lf1"), cont,
44 TestUtils.buildQName("name_test", "identityref:module", "2013-12-2"), ModifyAction.CREATE, null);
45 cont.getChildren().add(lf1);