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());
}
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());
}
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());
}
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));
}
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());
}
Aggregations