use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class RestconfImplTest method testRpcForMountpoint.
@Test
public void testRpcForMountpoint() throws Exception {
final UriInfo uriInfo = mock(UriInfo.class);
doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters(anyBoolean());
final NormalizedNodeContext ctx = mock(NormalizedNodeContext.class);
final InstanceIdentifierContext<?> iiCtx = mock(InstanceIdentifierContext.class);
doReturn(iiCtx).when(ctx).getInstanceIdentifierContext();
final SchemaNode schemaNode = mock(SchemaNode.class);
doReturn(schemaNode).when(iiCtx).getSchemaNode();
doReturn(QName.create("namespace", "2010-10-10", "localname")).when(schemaNode).getQName();
final DOMMountPoint mount = mock(DOMMountPoint.class);
doReturn(mount).when(iiCtx).getMountPoint();
final DOMRpcService rpcService = mock(DOMRpcService.class);
doReturn(Optional.of(rpcService)).when(mount).getService(DOMRpcService.class);
doReturn(immediateFluentFuture(mock(DOMRpcResult.class))).when(rpcService).invokeRpc(any(QName.class), any(NormalizedNode.class));
this.restconfImpl.invokeRpc("randomId", ctx, uriInfo);
this.restconfImpl.invokeRpc("ietf-netconf", ctx, uriInfo);
verify(rpcService, times(2)).invokeRpc(any(QName.class), any());
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class RestconfImplTest method createNotificationStreamTest.
/**
* Create notification stream for toaster module.
*/
@Test
public void createNotificationStreamTest() {
final NormalizedNodeContext payload = mock(NormalizedNodeContext.class);
final InstanceIdentifierContext<?> iiCtx = mock(InstanceIdentifierContext.class);
doReturn(iiCtx).when(payload).getInstanceIdentifierContext();
final SchemaNode schemaNode = mock(SchemaNode.class, Mockito.withSettings().extraInterfaces(RpcDefinition.class));
doReturn(schemaNode).when(iiCtx).getSchemaNode();
doReturn(QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "2014-01-14", "create-notification-stream")).when(schemaNode).getQName();
doReturn(null).when(iiCtx).getMountPoint();
final Set<DataContainerChild> children = new HashSet<>();
final DataContainerChild child = mock(DataContainerChild.class, Mockito.withSettings().extraInterfaces(LeafSetNode.class));
final LeafSetEntryNode entryNode = mock(LeafSetEntryNode.class);
when(entryNode.body()).thenReturn("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)toastDone");
when(((LeafSetNode) child).body()).thenReturn(Sets.newHashSet(entryNode));
children.add(child);
final NormalizedNode normalizedNode = mock(NormalizedNode.class, Mockito.withSettings().extraInterfaces(ContainerNode.class));
doReturn(normalizedNode).when(payload).getData();
doReturn(children).when(normalizedNode).body();
// register notification
final NormalizedNodeContext context = this.restconfImpl.invokeRpc("sal-remote:create-notification-stream", payload, null);
assertNotNull(context);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class RestPutConfigTest method testPutConfigDataCheckOnlyLastElement.
@Test
public void testPutConfigDataCheckOnlyLastElement() {
final String identifier = "test-interface:interfaces/interface/key/sub-interface/subkey";
final InstanceIdentifierContext<?> iiCx = this.controllerCx.toInstanceIdentifier(identifier);
final MapEntryNode data = Mockito.mock(MapEntryNode.class);
final QName qName = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "sub-interface");
final QName qNameSubKey = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "sub-name");
final NodeIdentifierWithPredicates identWithPredicates = NodeIdentifierWithPredicates.of(qName, qNameSubKey, "subkey");
Mockito.when(data.getIdentifier()).thenReturn(identWithPredicates);
final NormalizedNodeContext payload = new NormalizedNodeContext(iiCx, data);
mockingBrokerPut(iiCx.getInstanceIdentifier(), data);
final UriInfo uriInfo = Mockito.mock(UriInfo.class);
final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
this.restconfService.updateConfigurationData(identifier, payload, uriInfo);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class RestPutConfigTest method testPutConfigData.
@Test
public void testPutConfigData() {
final String identifier = "test-interface:interfaces/interface/key";
final InstanceIdentifierContext<?> iiCx = this.controllerCx.toInstanceIdentifier(identifier);
final MapEntryNode data = Mockito.mock(MapEntryNode.class);
final QName qName = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "interface");
final QName qNameKey = QName.create("urn:ietf:params:xml:ns:yang:test-interface", "2014-07-01", "name");
final NodeIdentifierWithPredicates identWithPredicates = NodeIdentifierWithPredicates.of(qName, qNameKey, "key");
Mockito.when(data.getIdentifier()).thenReturn(identWithPredicates);
final NormalizedNodeContext payload = new NormalizedNodeContext(iiCx, data);
mockingBrokerPut(iiCx.getInstanceIdentifier(), data);
final UriInfo uriInfo = Mockito.mock(UriInfo.class);
final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
this.restconfService.updateConfigurationData(identifier, payload, uriInfo);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class RestconfDocumentedExceptionMapperTest method testToResponseWithStatusOnly.
@Test
@Ignore
public void testToResponseWithStatusOnly() throws Exception {
// The StructuredDataToJsonProvider should throw a
// RestconfDocumentedException with no data
when(mockRestConf.readOperationalData(any(String.class), any(UriInfo.class))).thenReturn(new NormalizedNodeContext(null, null));
final Response resp = target("/operational/foo").request(MediaType.APPLICATION_JSON).get();
verifyResponse(resp, MediaType.TEXT_PLAIN, Status.NOT_FOUND);
}
Aggregations