Search in sources :

Example 1 with DOMMountPoint

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());
}
Also used : DOMMountPointListener(org.opendaylight.mdsal.dom.api.DOMMountPointListener) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) Test(org.junit.Test)

Example 2 with DOMMountPoint

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());
}
Also used : DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) DOMMountPointListener(org.opendaylight.mdsal.dom.api.DOMMountPointListener) DOMMountPointBuilder(org.opendaylight.mdsal.dom.api.DOMMountPointService.DOMMountPointBuilder) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) Test(org.junit.Test)

Example 3 with DOMMountPoint

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());
        }
    };
}
Also used : AbstractObjectRegistration(org.opendaylight.yangtools.concepts.AbstractObjectRegistration) SimpleDOMMountPoint(org.opendaylight.mdsal.dom.spi.SimpleDOMMountPoint) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 4 with DOMMountPoint

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);
}
Also used : DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 5 with DOMMountPoint

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());
}
Also used : ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) SchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) QName(org.opendaylight.yangtools.yang.common.QName) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) UriInfo(javax.ws.rs.core.UriInfo) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) Test(org.junit.Test)

Aggregations

DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)38 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)16 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)15 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)13 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)9 NormalizedNodeContext (org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext)8 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)8 MdsalRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy)7 RestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy)7 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)6 Test (org.junit.Test)5 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)5 QName (org.opendaylight.yangtools.yang.common.QName)5 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 DOMDataTreeReadWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction)4 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)4 SchemaNode (org.opendaylight.yangtools.yang.model.api.SchemaNode)4