Search in sources :

Example 1 with DOMMountPointService

use of org.opendaylight.mdsal.dom.api.DOMMountPointService in project netconf by opendaylight.

the class NetconfTopologyManagerTest method setUp.

@Before
public void setUp() throws Exception {
    AbstractDataBrokerTest dataBrokerTest = new AbstractDataBrokerTest() {

        @Override
        protected Set<YangModuleInfo> getModuleInfos() throws Exception {
            return ImmutableSet.of(BindingReflections.getModuleInfo(NetworkTopology.class), BindingReflections.getModuleInfo(Topology.class));
        }
    };
    dataBrokerTest.setup();
    dataBroker = spy(dataBrokerTest.getDataBroker());
    final DOMRpcProviderService rpcProviderRegistry = mock(DOMRpcProviderService.class);
    final ScheduledThreadPool keepaliveExecutor = mock(ScheduledThreadPool.class);
    final DOMActionProviderService actionProviderRegistry = mock(DOMActionProviderService.class);
    final ThreadPool processingThreadPool = mock(ThreadPool.class);
    final ExecutorService processingService = mock(ExecutorService.class);
    doReturn(processingService).when(processingThreadPool).getExecutor();
    final ActorSystemProvider actorSystemProvider = mock(ActorSystemProvider.class);
    final EventExecutor eventExecutor = mock(EventExecutor.class);
    final NetconfClientDispatcher clientDispatcher = mock(NetconfClientDispatcher.class);
    final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
    final AAAEncryptionService encryptionService = mock(AAAEncryptionService.class);
    final DeviceActionFactory deviceActionFactory = mock(DeviceActionFactory.class);
    final RpcProviderService rpcProviderService = mock(RpcProviderService.class);
    final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(Uint16.ZERO).build();
    netconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, dataBroker, rpcProviderRegistry, actionProviderRegistry, clusterSingletonServiceProvider, keepaliveExecutor, processingThreadPool, actorSystemProvider, eventExecutor, clientDispatcher, TOPOLOGY_ID, config, mountPointService, encryptionService, rpcProviderService, deviceActionFactory, new DefaultSchemaResourceManager(new DefaultYangParserFactory())) {

        @Override
        protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime, final DeviceActionFactory deviceActionFactory) {
            assertEquals(ACTOR_RESPONSE_WAIT_TIME.toJava(), actorResponseWaitTime.duration().toSeconds());
            return Objects.requireNonNull(mockContextMap.get(setup.getInstanceIdentifier()), "No mock context for " + setup.getInstanceIdentifier()).apply(setup);
        }
    };
    doNothing().when(mockListenerReg).close();
    doReturn(mockListenerReg).when(dataBroker).registerDataTreeChangeListener(any(), any());
}
Also used : RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) Config(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config) ThreadPool(org.opendaylight.controller.config.threadpool.ThreadPool) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) ActorSystemProvider(org.opendaylight.controller.cluster.ActorSystemProvider) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) AAAEncryptionService(org.opendaylight.aaa.encrypt.AAAEncryptionService) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) DefaultSchemaResourceManager(org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Timeout(akka.util.Timeout) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) DOMActionProviderService(org.opendaylight.mdsal.dom.api.DOMActionProviderService) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) EventExecutor(io.netty.util.concurrent.EventExecutor) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) ExecutorService(java.util.concurrent.ExecutorService) NetconfClientDispatcher(org.opendaylight.netconf.client.NetconfClientDispatcher) Before(org.junit.Before)

Example 2 with DOMMountPointService

use of org.opendaylight.mdsal.dom.api.DOMMountPointService in project netconf by opendaylight.

the class ApiDocServiceImplTest method setUp.

@Before
public void setUp() {
    final EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/yang");
    final DOMSchemaService schemaService = DocGenTestHelper.createMockSchemaService(context);
    final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
    when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService));
    final DOMMountPointService service = mock(DOMMountPointService.class);
    when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint));
    final MountPointSwaggerGeneratorDraft02 mountPointDraft02 = new MountPointSwaggerGeneratorDraft02(schemaService, service);
    final MountPointSwaggerGeneratorRFC8040 mountPointRFC8040 = new MountPointSwaggerGeneratorRFC8040(schemaService, service);
    final ApiDocGeneratorDraftO2 apiDocGeneratorDraftO2 = new ApiDocGeneratorDraftO2(schemaService);
    final ApiDocGeneratorRFC8040 apiDocGeneratorRFC8040 = new ApiDocGeneratorRFC8040(schemaService);
    mountPointDraft02.getMountPointSwagger().onMountPointCreated(INSTANCE_ID);
    final AllModulesDocGenerator allModulesDocGenerator = new AllModulesDocGenerator(apiDocGeneratorDraftO2, apiDocGeneratorRFC8040);
    apiDocService = new ApiDocServiceImpl(mountPointDraft02, mountPointRFC8040, apiDocGeneratorDraftO2, apiDocGeneratorRFC8040, allModulesDocGenerator);
}
Also used : MountPointSwaggerGeneratorDraft02(org.opendaylight.netconf.sal.rest.doc.impl.MountPointSwaggerGeneratorDraft02) ApiDocGeneratorDraftO2(org.opendaylight.netconf.sal.rest.doc.impl.ApiDocGeneratorDraftO2) AllModulesDocGenerator(org.opendaylight.netconf.sal.rest.doc.impl.AllModulesDocGenerator) MountPointSwaggerGeneratorRFC8040(org.opendaylight.netconf.sal.rest.doc.impl.MountPointSwaggerGeneratorRFC8040) ApiDocServiceImpl(org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) ApiDocGeneratorRFC8040(org.opendaylight.netconf.sal.rest.doc.impl.ApiDocGeneratorRFC8040) Before(org.junit.Before)

Example 3 with DOMMountPointService

use of org.opendaylight.mdsal.dom.api.DOMMountPointService in project netconf by opendaylight.

the class MountPointSwaggerTest method setUp.

@Before
public void setUp() {
    // We are sharing the global schema service and the mount schema service
    // in our test.
    // OK for testing - real thing would have separate instances.
    final EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/yang");
    final DOMSchemaService schemaService = DocGenTestHelper.createMockSchemaService(context);
    final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
    when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService));
    final DOMMountPointService service = mock(DOMMountPointService.class);
    when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint));
    final MountPointSwaggerGeneratorDraft02 generator = new MountPointSwaggerGeneratorDraft02(schemaService, service);
    swagger = generator.getMountPointSwagger();
}
Also used : MountPointSwaggerGeneratorDraft02(org.opendaylight.netconf.sal.rest.doc.impl.MountPointSwaggerGeneratorDraft02) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Before(org.junit.Before)

Example 4 with DOMMountPointService

use of org.opendaylight.mdsal.dom.api.DOMMountPointService in project netconf by opendaylight.

the class TestRestconfUtils method newControllerContext.

public static ControllerContext newControllerContext(final EffectiveModelContext schemaContext, final DOMMountPoint mountInstance) {
    final DOMMountPointService mockMountService = mock(DOMMountPointService.class);
    if (mountInstance != null) {
        doReturn(Optional.of(FixedDOMSchemaService.of(() -> schemaContext))).when(mountInstance).getService(eq(DOMSchemaService.class));
        doReturn(Optional.ofNullable(mountInstance)).when(mockMountService).getMountPoint(any(YangInstanceIdentifier.class));
    }
    DOMSchemaService mockSchemaService = mock(DOMSchemaService.class);
    doReturn(schemaContext).when(mockSchemaService).getGlobalContext();
    DOMSchemaService mockDomSchemaService = mock(DOMSchemaService.class);
    doReturn(ImmutableClassToInstanceMap.of()).when(mockDomSchemaService).getExtensions();
    return ControllerContext.newInstance(mockSchemaService, mockMountService, mockDomSchemaService);
}
Also used : DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) FixedDOMSchemaService(org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService)

Example 5 with DOMMountPointService

use of org.opendaylight.mdsal.dom.api.DOMMountPointService in project mdsal by opendaylight.

the class BindingDOMMountPointServiceAdapterTest method basicTest.

@Test
public void basicTest() throws Exception {
    final BindingDOMCodecServices registry = mock(BindingDOMCodecServices.class);
    final AdapterContext codec = new ConstantAdapterContext(registry);
    doReturn(YangInstanceIdentifier.empty()).when(registry).toYangInstanceIdentifier(any());
    final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
    final BindingDOMMountPointServiceAdapter adapter = new BindingDOMMountPointServiceAdapter(codec, mountPointService);
    doReturn(Optional.empty()).when(mountPointService).getMountPoint(any());
    assertFalse(adapter.getMountPoint(InstanceIdentifier.create(BooleanContainer.class)).isPresent());
    doReturn(Optional.of(mock(DOMMountPoint.class))).when(mountPointService).getMountPoint(any());
    assertTrue(adapter.getMountPoint(InstanceIdentifier.create(BooleanContainer.class)).isPresent());
    assertNotNull(adapter.registerListener(InstanceIdentifier.create(BooleanContainer.class), mock(MountPointListener.class)));
}
Also used : BooleanContainer(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer) BindingDOMCodecServices(org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) Test(org.junit.Test)

Aggregations

DOMMountPointService (org.opendaylight.mdsal.dom.api.DOMMountPointService)5 Before (org.junit.Before)3 DOMSchemaService (org.opendaylight.mdsal.dom.api.DOMSchemaService)3 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)2 MountPointSwaggerGeneratorDraft02 (org.opendaylight.netconf.sal.rest.doc.impl.MountPointSwaggerGeneratorDraft02)2 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)2 Timeout (akka.util.Timeout)1 EventExecutor (io.netty.util.concurrent.EventExecutor)1 ExecutorService (java.util.concurrent.ExecutorService)1 Test (org.junit.Test)1 AAAEncryptionService (org.opendaylight.aaa.encrypt.AAAEncryptionService)1 ActorSystemProvider (org.opendaylight.controller.cluster.ActorSystemProvider)1 ScheduledThreadPool (org.opendaylight.controller.config.threadpool.ScheduledThreadPool)1 ThreadPool (org.opendaylight.controller.config.threadpool.ThreadPool)1 RpcProviderService (org.opendaylight.mdsal.binding.api.RpcProviderService)1 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)1 BindingDOMCodecServices (org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices)1 DOMActionProviderService (org.opendaylight.mdsal.dom.api.DOMActionProviderService)1 DOMRpcProviderService (org.opendaylight.mdsal.dom.api.DOMRpcProviderService)1 FixedDOMSchemaService (org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService)1