Search in sources :

Example 41 with NormalizedNodeContext

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

the class TestXmlBodyReader method moduleDataTest.

@Test
public void moduleDataTest() throws Exception {
    final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
    final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName());
    final String uri = "instance-identifier-module:cont";
    mockBodyReader(uri, this.xmlBodyReader, false);
    final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
    final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
    checkNormalizedNodeContext(returnValue);
    checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) InputStream(java.io.InputStream) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Test(org.junit.Test)

Example 42 with NormalizedNodeContext

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

the class NnToXmlTest method nnAsYangUint32ToXmlTest.

@Test
public void nnAsYangUint32ToXmlTest() throws Exception {
    final String elName = "lfUint32";
    final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.uint32Type()).deserialize("4123456789"), elName);
    nnToXml(normalizedNodeContext, "<" + elName + ">4123456789</" + 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 43 with NormalizedNodeContext

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

the class NnToXmlTest method nnAsYangInt32ToXmlTest.

@Test
public void nnAsYangInt32ToXmlTest() throws Exception {
    final String elName = "lfInt32";
    final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.int32Type()).deserialize("201234"), elName);
    nnToXml(normalizedNodeContext, "<" + elName + ">201234</" + 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 44 with NormalizedNodeContext

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

the class NnToXmlTest method prepareIdrefData.

private static NormalizedNodeContext prepareIdrefData(final String prefix, final boolean valueAsQName) {
    final QName cont = QName.create("basic:module", "2013-12-02", "cont");
    final QName cont1 = QName.create("basic:module", "2013-12-02", "cont1");
    final QName lf11 = QName.create("basic:module", "2013-12-02", "lf11");
    final YangInstanceIdentifier yII = YangInstanceIdentifier.builder().node(cont).build();
    final DataSchemaNode contSchema = schemaContext.getDataChildByName(cont);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> contData = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) contSchema);
    final DataSchemaNode cont1Schema = ((ContainerSchemaNode) contSchema).getDataChildByName(cont1);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> cont1Data = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) cont1Schema);
    Object value = null;
    if (valueAsQName) {
        value = QName.create("referenced:module", "2013-12-02", "iden");
    } else {
        value = "no qname value";
    }
    final List<DataSchemaNode> instanceLf = ControllerContext.findInstanceDataChildrenByName((DataNodeContainer) cont1Schema, lf11.getLocalName());
    final DataSchemaNode schemaLf = Iterables.getFirst(instanceLf, null);
    cont1Data.withChild(SchemaAwareBuilders.leafBuilder((LeafSchemaNode) schemaLf).withValue(value).build());
    contData.withChild(cont1Data.build());
    final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext(new InstanceIdentifierContext<>(yII, contSchema, null, schemaContext), contData.build());
    return testNormalizedNodeContext;
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext)

Example 45 with NormalizedNodeContext

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

the class NnToXmlTest method snAsYangUint64ToXmlTest.

@Test
public void snAsYangUint64ToXmlTest() throws Exception {
    final String elName = "lfUint64";
    final NormalizedNodeContext normalizedNodeContext = prepareNNC(TypeDefinitionAwareCodec.from(BaseTypes.uint64Type()).deserialize("5123456789"), elName);
    nnToXml(normalizedNodeContext, "<" + elName + ">5123456789</" + 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)

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