Search in sources :

Example 6 with NormalizedNodePayload

use of org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload in project netconf by opendaylight.

the class XmlBodyReaderMountPointTest method moduleSubContainerDataPutTest.

@Test
public void moduleSubContainerDataPutTest() throws Exception {
    final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
    final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
    mockBodyReader(uri, xmlBodyReader, false);
    final NormalizedNodePayload payload = xmlBodyReader.readFrom(null, null, null, mediaType, null, XmlBodyReaderMountPointTest.class.getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml"));
    checkMountPointNormalizedNodePayload(payload);
    checkExpectValueNormalizeNodeContext(dataSchemaNode, payload, QName.create(dataSchemaNode.getQName(), "cont1"));
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) XmlBodyReaderTest(org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest) AbstractBodyReaderTest(org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest) Test(org.junit.Test)

Example 7 with NormalizedNodePayload

use of org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload in project netconf by opendaylight.

the class XmlBodyReaderMountPointTest method moduleDataTest.

@Test
public void moduleDataTest() throws Exception {
    final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
    final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
    mockBodyReader(uri, xmlBodyReader, false);
    final NormalizedNodePayload payload = xmlBodyReader.readFrom(null, null, null, mediaType, null, XmlBodyReaderMountPointTest.class.getResourceAsStream("/instanceidentifier/xml/xmldata.xml"));
    checkMountPointNormalizedNodePayload(payload);
    checkExpectValueNormalizeNodeContext(dataSchemaNode, payload);
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) XmlBodyReaderTest(org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest) AbstractBodyReaderTest(org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest) Test(org.junit.Test)

Example 8 with NormalizedNodePayload

use of org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload in project netconf by opendaylight.

the class XmlBodyReaderMountPointTest method moduleSubContainerDataPostActionTest.

@Test
public void moduleSubContainerDataPostActionTest() throws Exception {
    final Optional<DataSchemaNode> dataSchemaNode = schemaContext.findDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
    final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1/reset";
    mockBodyReader(uri, xmlBodyReader, true);
    final NormalizedNodePayload pyaload = xmlBodyReader.readFrom(null, null, null, mediaType, null, XmlBodyReaderMountPointTest.class.getResourceAsStream("/instanceidentifier/xml/xml_cont_action.xml"));
    checkMountPointNormalizedNodePayload(pyaload);
    checkExpectValueNormalizeNodeContext(dataSchemaNode.get(), pyaload);
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) XmlBodyReaderTest(org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest) AbstractBodyReaderTest(org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest) Test(org.junit.Test)

Example 9 with NormalizedNodePayload

use of org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload in project netconf by opendaylight.

the class PlainPatchDataTransactionUtilTest method testPatchListData.

@Test
public void testPatchListData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iidJukebox, schemaNodeForJukebox, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, jukeboxContainerWithPlaylist);
    doReturn(readWrite).when(mockDataBroker).newReadWriteTransaction();
    doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).merge(any(), any(), any(), any());
    PlainPatchDataTransactionUtil.patchData(payload, new MdsalRestconfStrategy(mockDataBroker), schema);
    verify(readWrite).merge(LogicalDatastoreType.CONFIGURATION, iidJukebox, payload.getData());
    PlainPatchDataTransactionUtil.patchData(payload, new NetconfRestconfStrategy(netconfService), schema);
    verify(netconfService).merge(LogicalDatastoreType.CONFIGURATION, iidJukebox, payload.getData(), Optional.empty());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) MdsalRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NetconfRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 10 with NormalizedNodePayload

use of org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload in project netconf by opendaylight.

the class PutDataTransactionUtilTest method testValidTopLevelNodeNamePathEmpty.

@Test
public void testValidTopLevelNodeNamePathEmpty() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid, schemaNode, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildLeaf);
    // FIXME: more asserts
    assertThrows(RestconfDocumentedException.class, () -> RestconfDataServiceImpl.validTopLevelNodeName(YangInstanceIdentifier.empty(), payload));
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Aggregations

NormalizedNodePayload (org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload)57 Test (org.junit.Test)53 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)33 InstanceIdentifierContext (org.opendaylight.restconf.common.context.InstanceIdentifierContext)24 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)21 MdsalRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy)13 QName (org.opendaylight.yangtools.yang.common.QName)13 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)12 NetconfRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy)12 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)12 Response (javax.ws.rs.core.Response)10 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)10 AbstractBodyReaderTest (org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest)7 XmlBodyReaderTest (org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest)7 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)6 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)5 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)5 ActionDefinition (org.opendaylight.yangtools.yang.model.api.ActionDefinition)5 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)5 SchemaNode (org.opendaylight.yangtools.yang.model.api.SchemaNode)5