Search in sources :

Example 26 with NormalizedNodePayload

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

the class RestconfStreamsSubscriptionServiceImplTest method testSubscribeToStreamWS.

@Test
public void testSubscribeToStreamWS() {
    ListenersBroker.getInstance().registerDataChangeListener(IdentifierCodec.deserialize("toaster:toaster/toasterStatus", schemaHandler.get()), "data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE", NotificationOutputType.XML);
    final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService = new RestconfStreamsSubscriptionServiceImpl(dataBroker, notificationService, schemaHandler, configurationWs);
    final NormalizedNodePayload response = streamsSubscriptionService.subscribeToStream("data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE", uriInfo);
    assertEquals("ws://localhost:8181/" + RestconfConstants.BASE_URI_PATTERN + "/data-change-event-subscription/toaster:toaster/toasterStatus/" + "datastore=OPERATIONAL/scope=ONE", response.getNewHeaders().get("Location").toString());
}
Also used : NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 27 with NormalizedNodePayload

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

the class RestconfStreamsSubscriptionServiceImplTest method testSubscribeToStreamSSE.

@Test
public void testSubscribeToStreamSSE() {
    ListenersBroker.getInstance().registerDataChangeListener(IdentifierCodec.deserialize("toaster:toaster/toasterStatus", schemaHandler.get()), "data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE", NotificationOutputType.XML);
    final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService = new RestconfStreamsSubscriptionServiceImpl(dataBroker, notificationService, schemaHandler, configurationSse);
    final NormalizedNodePayload response = streamsSubscriptionService.subscribeToStream("data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE", uriInfo);
    assertEquals("http://localhost:8181/" + RestconfConstants.BASE_URI_PATTERN + "/" + RestconfConstants.NOTIF + "/data-change-event-subscription/toaster:toaster/toasterStatus/" + "datastore=OPERATIONAL/scope=ONE", response.getNewHeaders().get("Location").toString());
}
Also used : NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 28 with NormalizedNodePayload

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

the class PutDataTransactionUtilTest method testPutCreateLeafData.

@Test
public void testPutCreateLeafData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid, schemaNode, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildLeaf);
    doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(iid);
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid, payload.getData(), Optional.empty());
    PutDataTransactionUtil.putData(payload, schema, new NetconfRestconfStrategy(netconfService), WriteDataParams.empty());
    verify(netconfService).getConfig(iid);
    verify(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid, payload.getData(), Optional.empty());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) 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 29 with NormalizedNodePayload

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

the class PutDataTransactionUtilTest method testValidTopLevelNodeNameWrongTopIdentifier.

@Test
public void testValidTopLevelNodeNameWrongTopIdentifier() {
    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(iid.getAncestor(1), 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)

Example 30 with NormalizedNodePayload

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

the class PutDataTransactionUtilTest method testPutReplaceListData.

@Test
public void testPutReplaceListData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid2, schemaNode2, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildBaseContWithList);
    doReturn(immediateFluentFuture(Optional.of(mock(NormalizedNode.class)))).when(netconfService).getConfig(iid2);
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid2, payload.getData(), Optional.empty());
    PutDataTransactionUtil.putData(payload, schema, new NetconfRestconfStrategy(netconfService), WriteDataParams.empty());
    verify(netconfService).getConfig(iid2);
    verify(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid2, payload.getData(), Optional.empty());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NetconfRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) 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