X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Fcnsn%2Fto%2Fjson%2Ftest%2FCnSnToJsonIdentityrefTest.java;h=d13b7b3eafc5b09843ffc5edce361b8539300626;hp=d664001d8c42cba422cb44c0864271a1ce2a7be3;hb=1e884647502a8d91f8a57bde8193c60b9bbcce0d;hpb=9303b14b9dba1a940f0d0a6fe1604bfcd0f9e294 diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonIdentityrefTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonIdentityrefTest.java index d664001d8c..d13b7b3eaf 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonIdentityrefTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonIdentityrefTest.java @@ -7,23 +7,8 @@ */ package org.opendaylight.controller.sal.restconf.impl.cnsn.to.json.test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.ws.rs.WebApplicationException; - import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider; -import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.*; -import org.opendaylight.yangtools.yang.data.impl.NodeFactory; public class CnSnToJsonIdentityrefTest extends YangAndXmlAndDataSchemaLoader { @@ -32,59 +17,4 @@ public class CnSnToJsonIdentityrefTest extends YangAndXmlAndDataSchemaLoader { dataLoad("/cnsn-to-json/identityref", 2, "identityref-module", "cont"); } - @Test - public void identityrefToJsonTest() { - String json = null; - try { - QName valueAsQname = TestUtils.buildQName("name_test", "identityref:module", "2013-12-2"); - json = TestUtils.writeCompNodeWithSchemaContextToOutput(prepareCompositeNode(valueAsQname), modules, - dataSchemaNode, StructuredDataToJsonProvider.INSTANCE); - } catch (WebApplicationException | IOException e) { - // shouldn't end here - assertTrue(false); - } - assertNotNull(json); - Pattern ptrn = Pattern.compile(".*\"lf1\"\\p{Space}*:\\p{Space}*\"identityref-module:name_test\".*", - Pattern.DOTALL); - Matcher mtch = ptrn.matcher(json); - - assertTrue(mtch.matches()); - } - - @Test - public void identityrefToJsonWithoutQNameTest() { - String json = null; - try { - String value = "not q name value"; - json = TestUtils.writeCompNodeWithSchemaContextToOutput(prepareCompositeNode(value), modules, - dataSchemaNode, StructuredDataToJsonProvider.INSTANCE); - } catch (WebApplicationException | IOException e) { - // shouldn't end here - assertTrue(false); - } - System.out.println(json); - assertNotNull(json); - Pattern ptrn = Pattern.compile(".*\"lf1\"\\p{Space}*:\\p{Space}*\"not q name value\".*", Pattern.DOTALL); - Matcher mtch = ptrn.matcher(json); - - assertTrue(mtch.matches()); - } - - private CompositeNode prepareCompositeNode(Object value) { - MutableCompositeNode cont = NodeFactory.createMutableCompositeNode(TestUtils.buildQName("cont"), null, null, - ModifyAction.CREATE, null); - MutableCompositeNode cont1 = NodeFactory.createMutableCompositeNode(TestUtils.buildQName("cont1"), cont, null, - ModifyAction.CREATE, null); - cont.getChildren().add(cont1); - - MutableSimpleNode lf1 = NodeFactory.createMutableSimpleNode(TestUtils.buildQName("lf1"), cont1, value, - ModifyAction.CREATE, null); - - cont1.getChildren().add(lf1); - cont1.init(); - cont.init(); - - return cont; - } - }