From b8e437c95f377664d900f94bd0630921b382d241 Mon Sep 17 00:00:00 2001 From: Gilles Thouenon Date: Wed, 15 Mar 2023 18:13:20 +0100 Subject: [PATCH] Migrate servicehandler module to OSGI DS - convert ServicehandlerImpl into a Component - remove unused parameter in ServicehandlerImpl - convert ServicehandlerProvider into a Component - replace the implementation type of listener parameters by their respective interface one in ServicehandlerProvider - convert NetworkModelListenerImpl into a Component - convert PceListenerImpl into a Component - convert RendererListenerImpl into a Component - convert ServiceListener into a Component - create interfaces for pce, renderer and network listeners - remove the servicehandler-blueprint.xml file - adapt ServicehandlerProviderTest, ServicehandlerImplTest and TapiConnectivityImplTest UT consequently JIRA: TRNSPRTPCE-736 Signed-off-by: Gilles Thouenon Change-Id: I7440863e9ae4df0bc209bab6674e7531b9521e53 (cherry picked from commit 3eaaac5f8c8bd69d6505053c00a014509b8ece6c) --- .../tpce/module/TransportPCEImpl.java | 12 ++- .../impl/ServicehandlerImpl.java | 36 ++++---- .../impl/ServicehandlerProvider.java | 64 ++++++-------- .../listeners/NetworkListener.java | 15 ++++ .../listeners/NetworkModelListenerImpl.java | 15 ++-- .../servicehandler/listeners/PceListener.java | 24 ++++++ .../listeners/PceListenerImpl.java | 20 +++-- .../listeners/RendererListener.java | 20 +++++ .../listeners/RendererListenerImpl.java | 15 +++- .../listeners/ServiceListener.java | 16 ++-- .../blueprint/servicehandler-blueprint.xml | 85 ------------------- .../impl/ServicehandlerImplTest.java | 58 ++++++------- .../impl/ServicehandlerProviderTest.java | 35 ++++---- .../TapiConnectivityImplTest.java | 22 ++--- tests/transportpce_tests/common/test_utils.py | 3 +- 15 files changed, 216 insertions(+), 224 deletions(-) create mode 100644 servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkListener.java create mode 100644 servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListener.java create mode 100644 servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListener.java delete mode 100644 servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml diff --git a/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java b/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java index 7b9c99c6b..0596c0890 100644 --- a/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java +++ b/lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java @@ -191,15 +191,15 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP lightyServices.getBindingNotificationPublishService(), serviceDataStoreOperations); NetworkModelListenerImpl networkModelListenerImpl = new NetworkModelListenerImpl( lightyServices.getBindingNotificationPublishService(), serviceDataStoreOperations); - ServicehandlerImpl servicehandler = new ServicehandlerImpl(lightyServices.getBindingDataBroker(), - pathComputationService, rendererServiceOperations, lightyServices.getBindingNotificationPublishService(), - pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); + ServicehandlerImpl servicehandler = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, + lightyServices.getBindingNotificationPublishService(), pceListenerImpl, rendererListenerImpl, + networkModelListenerImpl, serviceDataStoreOperations); ServiceListener serviceListener = new ServiceListener(servicehandler, serviceDataStoreOperations, lightyServices.getBindingNotificationPublishService()); servicehandlerProvider = new ServicehandlerProvider(lightyServices.getBindingDataBroker(), lightyServices.getRpcProviderService(), lightyServices.getNotificationService(), - serviceDataStoreOperations, pceListenerImpl, serviceListener, rendererListenerImpl, - networkModelListenerImpl, servicehandler); + serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, + lightyServices.getBindingNotificationPublishService(), servicehandler, serviceListener); if (activateTapi) { LOG.info("Creating tapi beans ..."); TapiLink tapiLink = new TapiLink(networkTransaction); @@ -240,8 +240,6 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP @Override protected boolean initProcedure() { - LOG.info("Initializing service-handler provider ..."); - servicehandlerProvider.init(); if (tapiProvider != null) { LOG.info("Initializing tapi provider ..."); tapiProvider.init(); diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java index 7d3d4f9ed..40dd9bde7 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java @@ -13,7 +13,6 @@ import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Map; import java.util.Optional; -import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.common.OperationResult; import org.opendaylight.transportpce.common.ResponseCodes; @@ -22,9 +21,9 @@ import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOpe import org.opendaylight.transportpce.servicehandler.DowngradeConstraints; import org.opendaylight.transportpce.servicehandler.ModelMappingUtils; import org.opendaylight.transportpce.servicehandler.ServiceInput; -import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl; +import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener; +import org.opendaylight.transportpce.servicehandler.listeners.PceListener; +import org.opendaylight.transportpce.servicehandler.listeners.RendererListener; import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper; import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; @@ -118,6 +117,9 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.pro import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,6 +127,7 @@ import org.slf4j.LoggerFactory; /** * Top level service interface providing main OpenROADM controller services. */ +@Component public class ServicehandlerImpl implements OrgOpenroadmServiceService { private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class); private static final String PUBLISHER = "ServiceHandler"; @@ -136,29 +139,30 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { private static final String SERVICE_DELETE_MSG = "serviceDelete: {}"; private static final String SERVICE_CREATE_MSG = "serviceCreate: {}"; - private DataBroker db; private ServiceDataStoreOperations serviceDataStoreOperations; private PCEServiceWrapper pceServiceWrapper; private RendererServiceWrapper rendererServiceWrapper; - private PceListenerImpl pceListenerImpl; - private RendererListenerImpl rendererListenerImpl; - private NetworkModelListenerImpl networkModelListenerImpl; + private PceListener pceListenerImpl; + private RendererListener rendererListenerImpl; + private NetworkListener networkModelListenerImpl; private NotificationPublishService notificationPublishService; - //TODO: remove private request fields as they are in global scope - - public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService, - RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService, - PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl, - NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations) { - this.db = databroker; + @Activate + public ServicehandlerImpl(@Reference PathComputationService pathComputationService, + @Reference RendererServiceOperations rendererServiceOperations, + @Reference NotificationPublishService notificationPublishService, + @Reference PceListener pceListenerImpl, + @Reference RendererListener rendererListenerImpl, + @Reference NetworkListener networkModelListenerImpl, + @Reference ServiceDataStoreOperations serviceDataStoreOperations) { this.serviceDataStoreOperations = serviceDataStoreOperations; + this.notificationPublishService = notificationPublishService; this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService); this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService); this.pceListenerImpl = pceListenerImpl; this.rendererListenerImpl = rendererListenerImpl; this.networkModelListenerImpl = networkModelListenerImpl; - this.notificationPublishService = notificationPublishService; + LOG.info("ServicehandlerImpl Initiated"); } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java index 379296038..658b50e45 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java @@ -9,14 +9,12 @@ package org.opendaylight.transportpce.servicehandler.impl; import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.ServiceListener; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TransportpceNetworkmodelListener; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener; @@ -27,6 +25,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,59 +38,48 @@ import org.slf4j.LoggerFactory; * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange * */ +@Component public class ServicehandlerProvider { private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class); private static final InstanceIdentifier SERVICE = InstanceIdentifier.builder(ServiceList.class) .child(Services.class).build(); - private final DataBroker dataBroker; - private final RpcProviderService rpcService; - private final NotificationService notificationService; private ListenerRegistration pcelistenerRegistration; - private ListenerRegistration serviceDataTreeChangeListenerRegistration; + private ListenerRegistration> serviceDataTreeChangeListenerRegistration; private ListenerRegistration rendererlistenerRegistration; private ListenerRegistration networkmodellistenerRegistration; private ObjectRegistration rpcRegistration; private ServiceDataStoreOperations serviceDataStoreOperations; - private PceListenerImpl pceListenerImpl; - private ServiceListener serviceListener; - private RendererListenerImpl rendererListenerImpl; - private NetworkModelListenerImpl networkModelListenerImpl; - private ServicehandlerImpl servicehandler; - public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderService rpcProviderService, - NotificationService notificationService, ServiceDataStoreOperations serviceDataStoreOperations, - PceListenerImpl pceListenerImpl, ServiceListener serviceListener, RendererListenerImpl rendererListenerImpl, - NetworkModelListenerImpl networkModelListenerImpl, ServicehandlerImpl servicehandler) { - this.dataBroker = dataBroker; - this.rpcService = rpcProviderService; - this.notificationService = notificationService; + @Activate + public ServicehandlerProvider(@Reference final DataBroker dataBroker, + @Reference RpcProviderService rpcProviderService, + @Reference NotificationService notificationService, + @Reference ServiceDataStoreOperations serviceDataStoreOperations, + @Reference TransportpcePceListener pceListenerImpl, + @Reference TransportpceRendererListener rendererListenerImpl, + @Reference TransportpceNetworkmodelListener networkModelListenerImpl, + @Reference NotificationPublishService notificationPublishService, + @Reference OrgOpenroadmServiceService servicehandler, + @Reference DataTreeChangeListener serviceListener) { this.serviceDataStoreOperations = serviceDataStoreOperations; this.serviceDataStoreOperations.initialize(); - this.pceListenerImpl = pceListenerImpl; - this.serviceListener = serviceListener; - this.rendererListenerImpl = rendererListenerImpl; - this.networkModelListenerImpl = networkModelListenerImpl; - this.servicehandler = servicehandler; - } - - /** - * Method called when the blueprint container is created. - */ - public void init() { - LOG.info("ServicehandlerProvider Session Initiated"); pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl); - serviceDataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener( - DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, SERVICE), serviceListener); rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl); networkmodellistenerRegistration = notificationService.registerNotificationListener(networkModelListenerImpl); - rpcRegistration = rpcService.registerRpcImplementation(OrgOpenroadmServiceService.class, servicehandler); + serviceDataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener( + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, SERVICE), serviceListener); + rpcRegistration = rpcProviderService + .registerRpcImplementation(OrgOpenroadmServiceService.class, servicehandler); + LOG.info("ServicehandlerProvider Session Initiated"); + LOG.info("Transportpce controller started"); } /** * Method called when the blueprint container is destroyed. */ + @Deactivate public void close() { LOG.info("ServicehandlerProvider Closed"); pcelistenerRegistration.close(); @@ -97,5 +88,4 @@ public class ServicehandlerProvider { networkmodellistenerRegistration.close(); rpcRegistration.close(); } - -} +} \ No newline at end of file diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkListener.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkListener.java new file mode 100644 index 000000000..6a839a083 --- /dev/null +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkListener.java @@ -0,0 +1,15 @@ +/* + * Copyright © 2023 Orange, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.transportpce.servicehandler.listeners; + +import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; + +public interface NetworkListener { + + void setserviceDataStoreOperations(ServiceDataStoreOperations serviceData); +} diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkModelListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkModelListenerImpl.java index c2e83a760..150cd98c7 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkModelListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkModelListenerImpl.java @@ -42,19 +42,22 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.path.PathDescriptionBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.ServicePathList; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NetworkModelListenerImpl implements TransportpceNetworkmodelListener { +@Component +public class NetworkModelListenerImpl implements TransportpceNetworkmodelListener, NetworkListener { private static final Logger LOG = LoggerFactory.getLogger(NetworkModelListenerImpl.class); - private final NotificationPublishService notificationPublishService; // to be used for T-API notification private ServiceDataStoreOperations serviceDataStoreOperations; private TopologyUpdateResult topologyUpdateResult; - public NetworkModelListenerImpl(NotificationPublishService notificationPublishService, - ServiceDataStoreOperations serviceDataStoreOperations) { - this.notificationPublishService = notificationPublishService; + @Activate + public NetworkModelListenerImpl(@Reference NotificationPublishService notificationPublishService, + @Reference ServiceDataStoreOperations serviceDataStoreOperations) { this.serviceDataStoreOperations = serviceDataStoreOperations; } @@ -105,7 +108,6 @@ public class NetworkModelListenerImpl implements TransportpceNetworkmodelListene continue; } Services services = serviceOptional.get(); - OperationResult operationResult1 = null; State newState; switch (services.getOperationalState()) { case InService: @@ -274,6 +276,7 @@ public class NetworkModelListenerImpl implements TransportpceNetworkmodelListene && topologyUpdateResult.getTopologyChanges().equals(notification.getTopologyChanges()); } + @Override public void setserviceDataStoreOperations(ServiceDataStoreOperations serviceData) { this.serviceDataStoreOperations = serviceData; } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListener.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListener.java new file mode 100644 index 000000000..07f8cce9b --- /dev/null +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListener.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2023 Orange, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.transportpce.servicehandler.listeners; + +import org.opendaylight.transportpce.servicehandler.ServiceInput; +import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; + +public interface PceListener { + + void setInput(ServiceInput serviceInput); + + void setServiceReconfigure(Boolean serv); + + void setserviceDataStoreOperations(ServiceDataStoreOperations serviceData); + + void setTempService(Boolean tempService); + + void setServiceFeasiblity(Boolean serviceFeasiblity); +} diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java index 665b18f52..2f6f970d4 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java @@ -30,10 +30,14 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificat import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PceListenerImpl implements TransportpcePceListener { +@Component +public class PceListenerImpl implements TransportpcePceListener, PceListener { private static final Logger LOG = LoggerFactory.getLogger(PceListenerImpl.class); private static final String PUBLISHER = "PceListener"; @@ -48,11 +52,12 @@ public class PceListenerImpl implements TransportpcePceListener { private Boolean serviceFeasiblity; private NotificationPublishService notificationPublishService; + @Activate public PceListenerImpl( - RendererServiceOperations rendererServiceOperations, - PathComputationService pathComputationService, - NotificationPublishService notificationPublishService, - ServiceDataStoreOperations serviceDataStoreOperations) { + @Reference RendererServiceOperations rendererServiceOperations, + @Reference PathComputationService pathComputationService, + @Reference NotificationPublishService notificationPublishService, + @Reference ServiceDataStoreOperations serviceDataStoreOperations) { this.rendererServiceOperations = rendererServiceOperations; this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService); this.serviceDataStoreOperations = serviceDataStoreOperations; @@ -295,22 +300,27 @@ public class PceListenerImpl implements TransportpcePceListener { return true; } + @Override public void setInput(ServiceInput serviceInput) { this.input = serviceInput; } + @Override public void setServiceReconfigure(Boolean serv) { this.serviceReconfigure = serv; } + @Override public void setserviceDataStoreOperations(ServiceDataStoreOperations serviceData) { this.serviceDataStoreOperations = serviceData; } + @Override public void setTempService(Boolean tempService) { this.tempService = tempService; } + @Override public void setServiceFeasiblity(Boolean serviceFeasiblity) { this.serviceFeasiblity = serviceFeasiblity; } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListener.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListener.java new file mode 100644 index 000000000..60215813c --- /dev/null +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListener.java @@ -0,0 +1,20 @@ +/* + * Copyright © 2023 Orange, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.transportpce.servicehandler.listeners; + +import org.opendaylight.transportpce.servicehandler.ServiceInput; +import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; + +public interface RendererListener { + + void setServiceInput(ServiceInput serviceInput); + + void setserviceDataStoreOperations(ServiceDataStoreOperations serviceData); + + void setTempService(Boolean tempService); +} diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java index f983d3774..87a75b622 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java @@ -33,6 +33,9 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificat import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +45,8 @@ import org.slf4j.LoggerFactory; * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange * */ -public class RendererListenerImpl implements TransportpceRendererListener { +@Component +public class RendererListenerImpl implements TransportpceRendererListener, RendererListener { private static final String PUBLISHER = "RendererListener"; private static final Logger LOG = LoggerFactory.getLogger(RendererListenerImpl.class); @@ -55,8 +59,10 @@ public class RendererListenerImpl implements TransportpceRendererListener { private final NetworkModelService networkModelService; - public RendererListenerImpl(PathComputationService pathComputationService, - NotificationPublishService notificationPublishService, NetworkModelService networkModelService) { + @Activate + public RendererListenerImpl(@Reference PathComputationService pathComputationService, + @Reference NotificationPublishService notificationPublishService, + @Reference NetworkModelService networkModelService) { this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService); setServiceInput(null); setTempService(false); @@ -274,14 +280,17 @@ public class RendererListenerImpl implements TransportpceRendererListener { return true; } + @Override public void setServiceInput(ServiceInput serviceInput) { this.input = serviceInput; } + @Override public void setserviceDataStoreOperations(ServiceDataStoreOperations serviceData) { this.serviceDataStoreOperations = serviceData; } + @Override public void setTempService(Boolean tempService) { this.tempService = tempService; } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java index 7caf6b2e1..63741688c 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java @@ -22,9 +22,7 @@ import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.common.ResponseCodes; -import org.opendaylight.transportpce.pce.service.PathComputationService; import org.opendaylight.transportpce.servicehandler.ServiceInput; -import org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.Restorable; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions; @@ -33,6 +31,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev2 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.resiliency.ServiceResiliency; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder; @@ -48,22 +47,27 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmServiceBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Component public class ServiceListener implements DataTreeChangeListener { private static final Logger LOG = LoggerFactory.getLogger(ServiceListener.class); private static final String PUBLISHER = "ServiceListener"; - private ServicehandlerImpl servicehandlerImpl; + private OrgOpenroadmServiceService servicehandlerImpl; private ServiceDataStoreOperations serviceDataStoreOperations; private NotificationPublishService notificationPublishService; - private PathComputationService pathComputationService; private Map mapServiceInputReroute; private final ScheduledExecutorService executor; - public ServiceListener(ServicehandlerImpl servicehandlerImpl, ServiceDataStoreOperations serviceDataStoreOperations, - NotificationPublishService notificationPublishService) { + @Activate + public ServiceListener(@Reference OrgOpenroadmServiceService servicehandlerImpl, + @Reference ServiceDataStoreOperations serviceDataStoreOperations, + @Reference NotificationPublishService notificationPublishService) { this.servicehandlerImpl = servicehandlerImpl; this.notificationPublishService = notificationPublishService; this.serviceDataStoreOperations = serviceDataStoreOperations; diff --git a/servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml b/servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml deleted file mode 100644 index 36dd8343c..000000000 --- a/servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java index 1806f20e6..1476041af 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java @@ -32,9 +32,9 @@ import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.transportpce.pce.service.PathComputationService; import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations; import org.opendaylight.transportpce.servicehandler.ServiceInput; -import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl; +import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener; +import org.opendaylight.transportpce.servicehandler.listeners.PceListener; +import org.opendaylight.transportpce.servicehandler.listeners.RendererListener; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl; import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils; @@ -90,11 +90,11 @@ public class ServicehandlerImplTest extends AbstractTest { @Mock private NotificationPublishService notificationPublishService; @Mock - private PceListenerImpl pceListenerImpl; + private PceListener pceListenerImpl; @Mock - private RendererListenerImpl rendererListenerImpl; + private RendererListener rendererListenerImpl; @Mock - private NetworkModelListenerImpl networkModelListenerImpl; + private NetworkListener networkModelListenerImpl; private ServiceDataStoreOperations serviceDataStoreOperations; private ServiceCreateInput serviceCreateInput; @@ -120,7 +120,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl @@ -141,7 +141,7 @@ public class ServicehandlerImplTest extends AbstractTest { new ServicesBuilder() .setServiceName(serviceCreateInput.getServiceName()) .build())); - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDSOperations); ListenableFuture> result = servicehandlerImpl.serviceCreate(serviceCreateInput); @@ -157,7 +157,7 @@ public class ServicehandlerImplTest extends AbstractTest { void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException { when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any())); - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceCreate(serviceCreateInput); @@ -171,7 +171,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceDelete( @@ -191,7 +191,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException { ServicehandlerImpl servicehandlerImpl = - new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations, + new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceDelete(serviceDeleteInput); @@ -206,7 +206,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException { when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any())); - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); serviceDataStoreOperations.createService(serviceCreateInput); @@ -222,7 +222,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = @@ -239,7 +239,7 @@ public class ServicehandlerImplTest extends AbstractTest { void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException { when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any())); - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = @@ -254,7 +254,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = @@ -268,7 +268,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException { //action -> service reconfigure - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceReconfigure( @@ -284,7 +284,7 @@ public class ServicehandlerImplTest extends AbstractTest { // serviceReconfigure is calling service delete method in renderer when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any())); //create service to reconfigure - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); serviceDataStoreOperations.createService(serviceCreateInput); @@ -300,7 +300,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl @@ -314,7 +314,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException { //action -> service restore - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.serviceRestoration( @@ -330,7 +330,7 @@ public class ServicehandlerImplTest extends AbstractTest { // serviceRestoration is calling service delete method in renderer when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any())); //create service to restore - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); serviceDataStoreOperations.createService(serviceCreateInput); @@ -346,7 +346,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = @@ -363,7 +363,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException { //action -> service reconfigure - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl @@ -437,8 +437,8 @@ public class ServicehandlerImplTest extends AbstractTest { .build()); serviceDataStoreOperations.createService(serviceCreateInput); - ListenableFuture> result = new ServicehandlerImpl(getNewDataBroker(), - pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, + ListenableFuture> result = new ServicehandlerImpl(pathComputationService, + rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations) .serviceReroute(serviceRerouteInput); result.addListener(() -> endSignal.countDown(), executorService); @@ -452,7 +452,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = @@ -472,7 +472,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = servicehandlerImpl.tempServiceDelete( @@ -490,7 +490,7 @@ public class ServicehandlerImplTest extends AbstractTest { when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any())); //create temp service to delete in the temp delete action - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput(); @@ -508,7 +508,7 @@ public class ServicehandlerImplTest extends AbstractTest { @Test void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); ListenableFuture> result = @@ -526,7 +526,7 @@ public class ServicehandlerImplTest extends AbstractTest { throws ExecutionException, InterruptedException { when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any())); - ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProviderTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProviderTest.java index b6da6dd72..8a696ab7e 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProviderTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProviderTest.java @@ -15,13 +15,16 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; -import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.ServiceListener; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.transportpce.test.AbstractTest; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TransportpceNetworkmodelListener; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services; @ExtendWith(MockitoExtension.class) public class ServicehandlerProviderTest extends AbstractTest { @@ -31,26 +34,24 @@ public class ServicehandlerProviderTest extends AbstractTest { @Mock ServiceDataStoreOperations serviceDataStoreOperations; @Mock - PceListenerImpl pceListenerImpl; + TransportpcePceListener pceListenerImpl; @Mock - ServiceListener serviceListener; + TransportpceRendererListener rendererListenerImpl; @Mock - RendererListenerImpl rendererListenerImpl; + TransportpceNetworkmodelListener networkModelListenerImpl; @Mock - NetworkModelListenerImpl networkModelListenerImpl; + NotificationPublishService notificationPublishService; @Mock - ServicehandlerImpl servicehandler; - + OrgOpenroadmServiceService servicehandler; + @Mock + DataTreeChangeListener serviceListener; @Test void testInitRegisterServiceHandlerToRpcRegistry() { - ServicehandlerProvider provider = new ServicehandlerProvider( - getDataBroker(), rpcProviderRegistry, - getNotificationService() , serviceDataStoreOperations, pceListenerImpl, serviceListener, - rendererListenerImpl, networkModelListenerImpl, servicehandler); - - provider.init(); + ServicehandlerProvider provider = new ServicehandlerProvider(getDataBroker(), rpcProviderRegistry, + getNotificationService() , serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, + networkModelListenerImpl, notificationPublishService, servicehandler, serviceListener); - verify(rpcProviderRegistry, times(1)).registerRpcImplementation(any(), any(ServicehandlerImpl.class)); + verify(rpcProviderRegistry, times(1)).registerRpcImplementation(any(), any(OrgOpenroadmServiceService.class)); } } \ No newline at end of file diff --git a/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java b/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java index bb0ae8789..8ae33a138 100644 --- a/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java +++ b/tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java @@ -32,9 +32,9 @@ import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.pce.service.PathComputationService; import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations; import org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl; -import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl; +import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener; +import org.opendaylight.transportpce.servicehandler.listeners.PceListener; +import org.opendaylight.transportpce.servicehandler.listeners.RendererListener; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl; import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl; @@ -77,11 +77,11 @@ public class TapiConnectivityImplTest extends AbstractTest { @Mock private TapiServiceHandlerListenerImpl tapiserviceHandlerListenerImpl; @Mock - private PceListenerImpl pceListenerImpl; + private PceListener pceListenerImpl; @Mock - private RendererListenerImpl rendererListenerImpl; + private RendererListener rendererListenerImpl; @Mock - private NetworkModelListenerImpl networkModelListenerImpl; + private NetworkListener networkModelListenerImpl; private static final Logger LOG = LoggerFactory.getLogger(TapiConnectivityImplTest.class); private static ServiceDataStoreOperations serviceDataStoreOperations; @@ -125,7 +125,7 @@ public class TapiConnectivityImplTest extends AbstractTest { @Test void createConnServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); @@ -150,7 +150,7 @@ public class TapiConnectivityImplTest extends AbstractTest { @Test void createConnServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException { - OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); @@ -176,7 +176,7 @@ public class TapiConnectivityImplTest extends AbstractTest { @Test void deleteConnServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException { - OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); @@ -201,7 +201,7 @@ public class TapiConnectivityImplTest extends AbstractTest { @Test void deleteConnServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException { DeleteConnectivityServiceInput input = TapiConnectivityDataUtils.buildConnServiceDeleteInput1(); - OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); @@ -226,7 +226,7 @@ public class TapiConnectivityImplTest extends AbstractTest { void deleteConnServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException { when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any())); - OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, + OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations); diff --git a/tests/transportpce_tests/common/test_utils.py b/tests/transportpce_tests/common/test_utils.py index 2f92031bc..58ccf122c 100644 --- a/tests/transportpce_tests/common/test_utils.py +++ b/tests/transportpce_tests/common/test_utils.py @@ -29,8 +29,7 @@ import simulators SIMS = simulators.SIMS HONEYNODE_OK_START_MSG = 'Netconf SSH endpoint started successfully at 0.0.0.0' -KARAF_OK_START_MSG = "Blueprint container for bundle org.opendaylight.transportpce.servicehandler.+" \ - "was successfully created" +KARAF_OK_START_MSG = "Transportpce controller started" LIGHTY_OK_START_MSG = re.escape("lighty.io and RESTCONF-NETCONF started") ODL_LOGIN = 'admin' -- 2.36.6