Search in sources :

Example 46 with NormalizedNodeContext

use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.

the class NnToXmlTest method nnAsYangEmptyToXmlTest.

@Test
public void nnAsYangEmptyToXmlTest() throws Exception {
    final String elName = "lfEmpty";
    final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.emptyType()).deserialize(""), elName);
    nnToXml(normalizedNodeContext, "<" + elName + "/>");
}
Also used : NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Test(org.junit.Test) AbstractBodyReaderTest(org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest)

Example 47 with NormalizedNodeContext

use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.

the class NnToXmlTest method nnAsYangInt8ToXmlTest.

@Test
public void nnAsYangInt8ToXmlTest() throws Exception {
    final String elName = "lfInt8";
    final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.int8Type()).deserialize("14"), elName);
    nnToXml(normalizedNodeContext, "<" + elName + ">14</" + elName + ">");
}
Also used : NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Test(org.junit.Test) AbstractBodyReaderTest(org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest)

Example 48 with NormalizedNodeContext

use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.

the class NnToXmlTest method nnAsYangBooleanToXmlTest.

@Test
public void nnAsYangBooleanToXmlTest() throws Exception {
    final String elName = "lfBoolean";
    NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.booleanType()).deserialize("false"), elName);
    nnToXml(normalizedNodeContext, "<" + elName + ">false</" + elName + ">");
    normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.booleanType()).deserialize("true"), elName);
    nnToXml(normalizedNodeContext, "<" + elName + ">true</" + elName + ">");
}
Also used : NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Test(org.junit.Test) AbstractBodyReaderTest(org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest)

Example 49 with NormalizedNodeContext

use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.

the class NnToXmlTest method nnAsYangIdentityrefWithQNamePrefixToXMLTest.

@Test
public void nnAsYangIdentityrefWithQNamePrefixToXMLTest() throws Exception {
    final NormalizedNodeContext normalizedNodeContext = prepareIdrefData("prefix", true);
    nnToXml(normalizedNodeContext, "<lf11 xmlns", "=\"referenced:module\">", ":iden</lf11>");
}
Also used : NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Test(org.junit.Test) AbstractBodyReaderTest(org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest)

Example 50 with NormalizedNodeContext

use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.

the class NnToXmlTest method nnAsYangEnumerationToXmlTest.

@Test
public void nnAsYangEnumerationToXmlTest() throws Exception {
    final EnumTypeDefinition.EnumPair mockEnum = Mockito.mock(EnumTypeDefinition.EnumPair.class);
    Mockito.when(mockEnum.getName()).thenReturn("enum2");
    final EnumerationTypeBuilder enumerationTypeBuilder = BaseTypes.enumerationTypeBuilder(QName.create("foo", "foo"));
    enumerationTypeBuilder.addEnum(mockEnum);
    final String elName = "lfEnumeration";
    final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(enumerationTypeBuilder.build()).deserialize("enum2"), elName);
    nnToXml(normalizedNodeContext, "<" + elName + ">enum2</" + elName + ">");
}
Also used : EnumTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition) EnumerationTypeBuilder(org.opendaylight.yangtools.yang.model.ri.type.EnumerationTypeBuilder) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Test(org.junit.Test) AbstractBodyReaderTest(org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest)

Aggregations

NormalizedNodeContext (org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext)105 Test (org.junit.Test)70 InputStream (java.io.InputStream)36 AbstractBodyReaderTest (org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest)34 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)34 QName (org.opendaylight.yangtools.yang.common.QName)25 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)22 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)21 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)18 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)13 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)13 Module (org.opendaylight.yangtools.yang.model.api.Module)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 OutputStream (java.io.OutputStream)9 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)9 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)9 UriInfo (javax.ws.rs.core.UriInfo)8 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)8 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)8 IOException (java.io.IOException)7