use of org.opendaylight.mdsal.dom.api.DOMMountPoint in project mdsal by opendaylight.
the class DOMMountPointServiceImplTest method testMountPointDestruction.
@Test
public void testMountPointDestruction() {
final DOMMountPointListener mountPointListener = mock(DOMMountPointListener.class);
doNothing().when(mountPointListener).onMountPointRemoved(PATH);
final ObjectRegistration<DOMMountPoint> mountPointRegistration = mountPointService.createMountPoint(PATH).register();
mountPointService.registerProvisionListener(mountPointListener);
mountPointRegistration.close();
// Verify listener has been notified and mount point is not present in mount point service
verify(mountPointListener).onMountPointRemoved(eq(PATH));
assertFalse(mountPointService.getMountPoint(PATH).isPresent());
}
use of org.opendaylight.mdsal.dom.api.DOMMountPoint in project mdsal by opendaylight.
the class DOMMountPointServiceImplTest method testMountPointRegistration.
@Test
public void testMountPointRegistration() {
final DOMMountPointListener mountPointListener = mock(DOMMountPointListener.class);
doNothing().when(mountPointListener).onMountPointCreated(PATH);
mountPointService.registerProvisionListener(mountPointListener);
// Create a mount point with schema context and a DOMService
final DOMMountPointBuilder mountPointBuilder = mountPointService.createMountPoint(PATH);
final DOMRpcService rpcService = mock(DOMRpcService.class);
mountPointBuilder.addService(DOMRpcService.class, rpcService);
mountPointBuilder.register();
// Verify listener has been notified and mount point is accessible from mount point service
verify(mountPointListener).onMountPointCreated(eq(PATH));
assertTrue(mountPointService.getMountPoint(PATH).isPresent());
// Verify mount point schema context and service
final DOMMountPoint mountPoint = mountPointService.getMountPoint(PATH).get();
assertTrue(mountPoint.getService(DOMRpcService.class).isPresent());
assertEquals(rpcService, mountPoint.getService(DOMRpcService.class).get());
}
use of org.opendaylight.mdsal.dom.api.DOMMountPoint in project mdsal by opendaylight.
the class DOMMountPointServiceImpl method registerMountPoint.
@SuppressWarnings("checkstyle:IllegalCatch")
private ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
final YangInstanceIdentifier mountPointId = mountPoint.getIdentifier();
synchronized (mountPoints) {
final DOMMountPoint prev = mountPoints.putIfAbsent(mountPointId, mountPoint);
checkState(prev == null, "Mount point %s already exists as %s", mountPointId, prev);
}
listeners.streamListeners().forEach(listener -> {
try {
listener.onMountPointCreated(mountPointId);
} catch (final Exception ex) {
LOG.error("Listener {} failed on mount point {} created event", listener, mountPoint, ex);
}
});
return new AbstractObjectRegistration<>(mountPoint) {
@Override
protected void removeRegistration() {
unregisterMountPoint(getInstance().getIdentifier());
}
};
}
use of org.opendaylight.mdsal.dom.api.DOMMountPoint in project mdsal by opendaylight.
the class BindingDOMMountPointServiceAdapter method getMountPoint.
@Override
public Optional<MountPoint> getMountPoint(final InstanceIdentifier<?> mountPoint) {
YangInstanceIdentifier domPath = currentSerializer().toCachedYangInstanceIdentifier(mountPoint);
Optional<DOMMountPoint> domMount = getDelegate().getMountPoint(domPath);
return domMount.map(this::getAdapter);
}
use of org.opendaylight.mdsal.dom.api.DOMMountPoint 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());
}
Aggregations