Migrate servicehandler module to OSGI DS 46/104946/6
authorGilles Thouenon <gilles.thouenon@orange.com>
Wed, 15 Mar 2023 17:13:20 +0000 (18:13 +0100)
committerGilles Thouenon <gilles.thouenon@orange.com>
Fri, 31 Mar 2023 07:35:48 +0000 (09:35 +0200)
- 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 <gilles.thouenon@orange.com>
Change-Id: I7440863e9ae4df0bc209bab6674e7531b9521e53
(cherry picked from commit 3eaaac5f8c8bd69d6505053c00a014509b8ece6c)

15 files changed:
lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkListener.java [new file with mode: 0644]
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/NetworkModelListenerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListener.java [new file with mode: 0644]
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListener.java [new file with mode: 0644]
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java
servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml [deleted file]
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProviderTest.java
tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java
tests/transportpce_tests/common/test_utils.py

index 7b9c99c6b2f16b2714f0ee917687a1dfe449fe71..0596c089030df6ea68a7957c77ba808d8e54699f 100644 (file)
@@ -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();
index 7d3d4f9edb7bcfde39b2cdc32d83bfd4100a121a..40dd9bde7a2add7bc8b3e18153b292d8aaf35c4a 100644 (file)
@@ -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");
     }
 
 
index 379296038f85ed463703a7ad40961b0acf4a347a..658b50e45daa24e8be8d2cec2694e740cb479edc 100644 (file)
@@ -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<Services> SERVICE = InstanceIdentifier.builder(ServiceList.class)
             .child(Services.class).build();
 
-    private final DataBroker dataBroker;
-    private final RpcProviderService rpcService;
-    private final NotificationService notificationService;
     private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
-    private ListenerRegistration<ServiceListener> serviceDataTreeChangeListenerRegistration;
+    private ListenerRegistration<DataTreeChangeListener<Services>> serviceDataTreeChangeListenerRegistration;
     private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
     private ListenerRegistration<TransportpceNetworkmodelListener> networkmodellistenerRegistration;
     private ObjectRegistration<OrgOpenroadmServiceService> 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<Services> 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 (file)
index 0000000..6a839a0
--- /dev/null
@@ -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);
+}
index c2e83a7607022127d71b3bf843f2edd38f2840fe..150cd98c72fba435847fa033b0f7cb5b3a051d29 100644 (file)
@@ -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 (file)
index 0000000..07f8cce
--- /dev/null
@@ -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);
+}
index 665b18f52415e035bbc876dd13f938489f94eaa7..2f6f970d4ce2cbd4b3bcefac320260f60c9d3fbe 100644 (file)
@@ -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 (file)
index 0000000..6021581
--- /dev/null
@@ -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);
+}
index f983d37745e172a30a9e4d0a6f19ef2ee2ff9b17..87a75b622b7d54bf2e64059514ad5440db8f3c2f 100644 (file)
@@ -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;
     }
index 7caf6b2e1331eb485fe1b0a48d97e90e8df1a2e8..63741688c3dd4a4d166bd3f32a1c37c0be80d26e 100644 (file)
@@ -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<Services> {
 
     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<String, ServiceInput> 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 (file)
index 36dd834..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright © 2017 Orange 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
-
-Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
-    <reference id="rpcService"
-          interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
-
-    <reference id="dataBroker"
-          interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
-
-    <reference id="notificationService"
-          interface="org.opendaylight.mdsal.binding.api.NotificationService"/>
-
-    <reference id="notificationPublishService"
-          interface="org.opendaylight.mdsal.binding.api.NotificationPublishService"/>
-
-    <reference id="pathComputationService"
-          interface="org.opendaylight.transportpce.pce.service.PathComputationService"/>
-
-    <reference id="rendererServiceOperations"
-             interface="org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations" />
-    <reference id="networkModelService" interface="org.opendaylight.transportpce.networkmodel.service.NetworkModelService"/>
-    <reference id="serviceDatastoreOperation" interface="org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations"/>
-
-    <bean id="pceListener" class="org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl">
-        <argument ref="rendererServiceOperations" />
-        <argument ref="pathComputationService" />
-        <argument ref="notificationPublishService" />
-        <argument ref="serviceDatastoreOperation" />
-    </bean>
-
-    <bean id="serviceListener" class="org.opendaylight.transportpce.servicehandler.listeners.ServiceListener">
-        <argument ref="serviceHandlerImpl" />
-        <argument ref="serviceDatastoreOperation" />
-        <argument ref="notificationPublishService" />
-    </bean>
-
-    <bean id="rendererListener" class="org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl">
-        <argument ref="pathComputationService" />
-        <argument ref="notificationPublishService" />
-        <argument ref="networkModelService" />
-    </bean>
-
-    <bean id="networkModelListener" class="org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl">
-        <argument ref="notificationPublishService" />
-        <argument ref="serviceDatastoreOperation" />
-    </bean>
-
-    <bean id="serviceHandlerImpl" class="org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl">
-        <argument ref="dataBroker"/>
-        <argument ref="pathComputationService" />
-        <argument ref="notificationPublishService" />
-        <argument ref="rendererServiceOperations" />
-        <argument ref="pceListener" />
-        <argument ref="rendererListener" />
-        <argument ref="networkModelListener" />
-        <argument ref="serviceDatastoreOperation" />
-    </bean>
-
-    <bean id="provider"
-          class="org.opendaylight.transportpce.servicehandler.impl.ServicehandlerProvider"
-          init-method="init" destroy-method="close">
-        <argument ref="rpcService" />
-        <argument ref="dataBroker" />
-        <argument ref="notificationService" />
-        <argument ref="serviceDatastoreOperation" />
-        <argument ref="pceListener" />
-        <argument ref="serviceListener" />
-        <argument ref="rendererListener" />
-        <argument ref="networkModelListener" />
-        <argument ref="serviceHandlerImpl" />
-    </bean>
-
-    <service ref="serviceHandlerImpl"
-        interface="org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService"/>
-</blueprint>
index 1806f20e6de2a486c3b1930414e1a46a76550205..1476041af288313b83af56493927108eef2133b6 100644 (file)
@@ -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<RpcResult<ServiceCreateOutput>> 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<RpcResult<ServiceCreateOutput>> 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<RpcResult<ServiceCreateOutput>> 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<RpcResult<ServiceDeleteOutput>> 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<RpcResult<ServiceDeleteOutput>> 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<RpcResult<ServiceFeasibilityCheckOutput>> 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<RpcResult<ServiceFeasibilityCheckOutput>> 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<RpcResult<ServiceReconfigureOutput>> 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<RpcResult<ServiceReconfigureOutput>> 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<RpcResult<ServiceRestorationOutput>> 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<RpcResult<ServiceRestorationOutput>> 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<RpcResult<ServiceRerouteOutput>> 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<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl
@@ -437,8 +437,8 @@ public class ServicehandlerImplTest extends AbstractTest {
                         .build());
 
         serviceDataStoreOperations.createService(serviceCreateInput);
-        ListenableFuture<RpcResult<ServiceRerouteOutput>> result =  new ServicehandlerImpl(getNewDataBroker(),
-                pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl,
+        ListenableFuture<RpcResult<ServiceRerouteOutput>> 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<RpcResult<TempServiceDeleteOutput>> 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<RpcResult<TempServiceDeleteOutput>> 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<RpcResult<TempServiceCreateOutput>> 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);
 
index b6da6dd72e5e91cd7036bd9573efe6852462cb7a..8a696ab7e2a5f6575d700c85b13249aa54f6978b 100644 (file)
@@ -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<Services> 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
index bb0ae8789630a0ecdca6eb9cd47fc25b85b09abb..8ae33a138daab7059a6d755f56aba5a4712dabe2 100644 (file)
@@ -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);
 
index 2f92031bc238e1078b4396e7128dcda854a3a877..58ccf122c22ba3c10bb8cea6586a96f495e0d348 100644 (file)
@@ -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'