Do not use RpcService in servicehandler module 84/108084/4
authorGilles Thouenon <gilles.thouenon@orange.com>
Sun, 1 Oct 2023 10:25:15 +0000 (12:25 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Wed, 11 Oct 2023 11:47:29 +0000 (13:47 +0200)
- Migrate usage of RpcService to the new style yang.binding.Rpc-based
implementation for servicehandler module
- Adapt lighty implementation

JIRA: TRNSPRTPCE-752
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: Id819475ab2acd7fbc30ea0e162485d38ee69e9a1

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/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

index ff08a080deb8d236a9426adab31f1db447bb116e..519a5d029f0ad5b3e78ec25436015633e4e65958 100644 (file)
@@ -176,13 +176,14 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP
                 lgServBNPS, serviceDataStoreOperations);
         NetworkModelListenerImpl networkModelListenerImpl = new NetworkModelListenerImpl(
                 lgServBNPS, serviceDataStoreOperations);
-        OrgOpenroadmServiceService servicehandler = new ServicehandlerImpl(
+        ServicehandlerImpl servicehandler = new ServicehandlerImpl(lgServRPS,
                 pathComputationService, rendererServiceOperations,
                 lgServBNPS, pceListenerImpl,
                 rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations,
                 new CatalogDataStoreOperationsImpl(networkTransaction));
+        rpcRegistrations.add(servicehandler.getRegisteredRpc());
         servicehandlerProvider = new ServicehandlerProvider(
-                lgServBDB, lgServRPS,
+                lgServBDB,
                 lgServNS, serviceDataStoreOperations, pceListenerImpl,
                 rendererListenerImpl, networkModelListenerImpl, lgServBNPS,
                 servicehandler,
index 0051deb332a2aa6a8fef6a0e1de85c520ee6567e..a5674cde5a8e549dbb97e590199789de9dd656ed 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.transportpce.servicehandler.impl;
 
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.time.OffsetDateTime;
 import java.time.ZoneOffset;
@@ -14,6 +15,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.Map;
 import java.util.Optional;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.OperationResult;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
@@ -46,76 +48,111 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.
 import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.rev230526.operational.mode.catalog.SpecificOperationalModes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.HardConstraints;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.SoftConstraints;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalog;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalog;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalActivationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalActivationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalActivationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalDeactivationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalDeactivationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalDeactivationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalPerformanceInfoRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalPerformanceInfoRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalPerformanceInfoRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalPowerControl;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalPowerControlInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EndTerminalPowerControlOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EquipmentNotification;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EquipmentNotificationInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.EquipmentNotificationOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.NetworkReOptimization;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.NetworkReOptimizationInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.NetworkReOptimizationOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OpticalTunnelCreate;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OpticalTunnelCreateInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OpticalTunnelCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OpticalTunnelRequestCancel;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OpticalTunnelRequestCancelInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OpticalTunnelRequestCancelOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OrgOpenroadmServiceService;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreate;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateBulk;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateBulkInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateBulkOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateComplexResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateComplexResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateComplexResultNotificationRequestOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateResultNotificationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDelete;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteComplexResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteComplexResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteComplexResultNotificationRequestOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteResultNotificationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheck;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckBulk;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckBulkInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckBulkOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigure;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureBulk;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureBulkInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureBulkOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureResultNotificationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReroute;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteConfirm;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteConfirmInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteConfirmOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteConfirmResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteConfirmResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteConfirmResultNotificationRequestOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestoration;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationResultNotificationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReversion;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReversionInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReversionOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReversionResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReversionResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReversionResultNotificationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRoll;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRollInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRollOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRollResultNotificationRequest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRollResultNotificationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRollResultNotificationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceSrlgGet;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceSrlgGetInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceSrlgGetOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreate;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateBulk;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateBulkInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateBulkOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDelete;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfo.TailRetention;
@@ -130,9 +167,12 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificat
 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.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.Rpc;
 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.Deactivate;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -163,9 +203,11 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     private NetworkListener networkModelListenerImpl;
     private NotificationPublishService notificationPublishService;
     private CatalogDataStoreOperations catalogDataStoreOperations;
+    private Registration reg;
 
     @Activate
-    public ServicehandlerImpl(@Reference PathComputationService pathComputationService,
+    public ServicehandlerImpl(@Reference RpcProviderService rpcProviderService,
+            @Reference PathComputationService pathComputationService,
             @Reference RendererServiceOperations rendererServiceOperations,
             @Reference NotificationPublishService notificationPublishService,
             @Reference PceListener pceListenerImpl,
@@ -181,9 +223,16 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
         this.pceListenerImpl = pceListenerImpl;
         this.rendererListenerImpl = rendererListenerImpl;
         this.networkModelListenerImpl = networkModelListenerImpl;
+        this.reg = rpcProviderService.registerRpcImplementations(registerRPCs());
         LOG.info("ServicehandlerImpl Initiated");
     }
 
+    @Deactivate
+    public void close() {
+        this.reg.close();
+        LOG.info("ServicehandlerImpl Closed");
+    }
+
 
     // This is class is public so that these messages can be accessed from Junit (avoid duplications).
     public static final class LogMessages {
@@ -232,7 +281,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
+    public final ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
         LOG.info("RPC serviceCreate received");
         // Validation
         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
@@ -288,7 +337,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
+    public final ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
         String serviceName = input.getServiceDeleteReqInfo().getServiceName();
         LOG.info("RPC serviceDelete request received for {}", serviceName);
 
@@ -358,7 +407,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
+    public final ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
             ServiceFeasibilityCheckInput input) {
         LOG.info("RPC serviceFeasibilityCheck received");
         // Validation
@@ -393,7 +442,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
+    public final ListenableFuture<RpcResult<
+            ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
         String serviceName = input.getServiceName();
         LOG.info("RPC serviceReconfigure received for {}", serviceName);
         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
@@ -439,7 +489,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
+    public final ListenableFuture<RpcResult<
+            ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
         String serviceName = input.getServiceName();
         LOG.info("RPC serviceRestoration received for {}", serviceName);
         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
@@ -515,21 +566,21 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
+    public final ListenableFuture<RpcResult<EquipmentNotificationOutput>>
             equipmentNotification(EquipmentNotificationInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
+    public final ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
             serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
+    public final ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
         String serviceName = input.getServiceName();
         LOG.info("RPC serviceReroute received for {}", serviceName);
         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
@@ -590,26 +641,26 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
+    public final ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
+    public final ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
+    public final ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
             networkReOptimization(NetworkReOptimizationInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
+    public final ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
         String commonId = input.getCommonId();
         LOG.info("RPC temp serviceDelete request received for {}", commonId);
 
@@ -667,7 +718,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
+    public final ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
         LOG.info("RPC tempServiceCreate received");
         // Validation
         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
@@ -712,7 +763,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<
+    public final ListenableFuture<RpcResult<
         ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
             ServiceDeleteComplexResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
@@ -720,7 +771,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<
+    public final ListenableFuture<RpcResult<
         ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
             ServiceCreateResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
@@ -728,7 +779,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<
+    public final ListenableFuture<RpcResult<
         ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
             ServiceDeleteResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
@@ -736,7 +787,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<
+    public final ListenableFuture<RpcResult<
         ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
             ServiceCreateComplexResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
@@ -744,89 +795,77 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
+    public final ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
         ServiceFeasibilityCheckBulkInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
-    /**
-     * Send notification to NBI notification in order to publish message.
-     * @param service PublishNotificationService
-     */
-    private void sendNbiNotification(PublishNotificationProcessService service) {
-        try {
-            notificationPublishService.putNotification(service);
-        } catch (InterruptedException e) {
-            LOG.warn("Cannot send notification to nbi", e);
-            Thread.currentThread().interrupt();
-        }
-    }
-
-
     @Override
-    public ListenableFuture<RpcResult<ServiceCreateBulkOutput>> serviceCreateBulk(ServiceCreateBulkInput input) {
+    public final ListenableFuture<RpcResult<ServiceCreateBulkOutput>> serviceCreateBulk(ServiceCreateBulkInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<TempServiceCreateBulkOutput>> tempServiceCreateBulk(
+    public final ListenableFuture<RpcResult<TempServiceCreateBulkOutput>> tempServiceCreateBulk(
         TempServiceCreateBulkInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceRollResultNotificationRequestOutput>> serviceRollResultNotificationRequest(
-        ServiceRollResultNotificationRequestInput input) {
+    public final ListenableFuture<RpcResult<
+        ServiceRollResultNotificationRequestOutput>> serviceRollResultNotificationRequest(
+            ServiceRollResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceReconfigureBulkOutput>> serviceReconfigureBulk(
+    public final ListenableFuture<RpcResult<ServiceReconfigureBulkOutput>> serviceReconfigureBulk(
         ServiceReconfigureBulkInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceReconfigureResultNotificationRequestOutput>>
+    public final ListenableFuture<RpcResult<ServiceReconfigureResultNotificationRequestOutput>>
             serviceReconfigureResultNotificationRequest(ServiceReconfigureResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceRestorationResultNotificationRequestOutput>>
+    public final ListenableFuture<RpcResult<ServiceRestorationResultNotificationRequestOutput>>
             serviceRestorationResultNotificationRequest(ServiceRestorationResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceReversionResultNotificationRequestOutput>>
+    public final ListenableFuture<RpcResult<ServiceReversionResultNotificationRequestOutput>>
             serviceReversionResultNotificationRequest(ServiceReversionResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceRerouteConfirmResultNotificationRequestOutput>>
+    public final ListenableFuture<RpcResult<ServiceRerouteConfirmResultNotificationRequestOutput>>
             serviceRerouteConfirmResultNotificationRequest(ServiceRerouteConfirmResultNotificationRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<OpticalTunnelCreateOutput>> opticalTunnelCreate(OpticalTunnelCreateInput input) {
+    public final ListenableFuture<RpcResult<
+            OpticalTunnelCreateOutput>> opticalTunnelCreate(OpticalTunnelCreateInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<OpticalTunnelRequestCancelOutput>> opticalTunnelRequestCancel(
+    public final ListenableFuture<RpcResult<OpticalTunnelRequestCancelOutput>> opticalTunnelRequestCancel(
             OpticalTunnelRequestCancelInput input) {
         // TODO Auto-generated method stub
         return null;
@@ -842,7 +881,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
      * @param input AddOpenroadmOperationalModesToCatalogInput to be added to Catalog
      * @return Result of the request
      */
-    public ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>>
+    public final ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>>
         addOpenroadmOperationalModesToCatalog(AddOpenroadmOperationalModesToCatalogInput input) {
 
         LOG.info("RPC addOpenroadmOperationalModesToCatalog in progress");
@@ -876,8 +915,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
      * @param input AddSpecificOperationalModesToCatalogInput to be added to Catalog
      * @return Result of the request
      */
-    public ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> addSpecificOperationalModesToCatalog(
-            AddSpecificOperationalModesToCatalogInput input) {
+    public final ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>>
+            addSpecificOperationalModesToCatalog(AddSpecificOperationalModesToCatalogInput input) {
 
         LOG.info("RPC addSpecificOperationalModesToCatalog in progress");
         LOG.debug(" Input openSpecificRoadm {}", input);
@@ -901,37 +940,97 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     }
 
     @Override
-    public ListenableFuture<RpcResult<ServiceSrlgGetOutput>> serviceSrlgGet(ServiceSrlgGetInput input) {
+    public final ListenableFuture<RpcResult<ServiceSrlgGetOutput>> serviceSrlgGet(ServiceSrlgGetInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<EndTerminalPerformanceInfoRequestOutput>> endTerminalPerformanceInfoRequest(
+    public final ListenableFuture<RpcResult<EndTerminalPerformanceInfoRequestOutput>> endTerminalPerformanceInfoRequest(
         EndTerminalPerformanceInfoRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<EndTerminalActivationRequestOutput>> endTerminalActivationRequest(
-        EndTerminalActivationRequestInput input) {
+    public final ListenableFuture<RpcResult<EndTerminalActivationRequestOutput>> endTerminalActivationRequest(
+            EndTerminalActivationRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<EndTerminalDeactivationRequestOutput>> endTerminalDeactivationRequest(
-        EndTerminalDeactivationRequestInput input) {
+    public final ListenableFuture<RpcResult<EndTerminalDeactivationRequestOutput>> endTerminalDeactivationRequest(
+            EndTerminalDeactivationRequestInput input) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public ListenableFuture<RpcResult<EndTerminalPowerControlOutput>> endTerminalPowerControl(
-        EndTerminalPowerControlInput input) {
+    public final ListenableFuture<RpcResult<EndTerminalPowerControlOutput>> endTerminalPowerControl(
+            EndTerminalPowerControlInput input) {
         // TODO Auto-generated method stub
         return null;
     }
+
+    public Registration getRegisteredRpc() {
+        return reg;
+    }
+
+    /**
+     * Send notification to NBI notification in order to publish message.
+     * @param service PublishNotificationService
+     */
+    private void sendNbiNotification(PublishNotificationProcessService service) {
+        try {
+            notificationPublishService.putNotification(service);
+        } catch (InterruptedException e) {
+            LOG.warn("Cannot send notification to nbi", e);
+            Thread.currentThread().interrupt();
+        }
+    }
+
+    private ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
+        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+            .put(ServiceCreate.class, this::serviceCreate)
+            .put(ServiceDelete.class, this::serviceDelete)
+            .put(ServiceFeasibilityCheck.class, this::serviceFeasibilityCheck)
+            .put(ServiceReconfigure.class, this::serviceReconfigure)
+            .put(ServiceRestoration.class, this::serviceRestoration)
+            .put(EquipmentNotification.class, this::equipmentNotification)
+            .put(ServiceRerouteConfirm.class, this::serviceRerouteConfirm)
+            .put(ServiceReroute.class, this::serviceReroute)
+            .put(ServiceReversion.class, this::serviceReversion)
+            .put(ServiceRoll.class, this::serviceRoll)
+            .put(NetworkReOptimization.class, this::networkReOptimization)
+            .put(TempServiceDelete.class, this::tempServiceDelete)
+            .put(TempServiceCreate.class, this::tempServiceCreate)
+            .put(ServiceDeleteComplexResultNotificationRequest.class,
+                this::serviceDeleteComplexResultNotificationRequest)
+            .put(ServiceCreateResultNotificationRequest.class, this::serviceCreateResultNotificationRequest)
+            .put(ServiceDeleteResultNotificationRequest.class, this::serviceDeleteResultNotificationRequest)
+            .put(ServiceCreateComplexResultNotificationRequest.class,
+                this::serviceCreateComplexResultNotificationRequest)
+            .put(ServiceFeasibilityCheckBulk.class, this::serviceFeasibilityCheckBulk)
+            .put(ServiceCreateBulk.class, this::serviceCreateBulk)
+            .put(TempServiceCreateBulk.class, this::tempServiceCreateBulk)
+            .put(ServiceRollResultNotificationRequest.class, this::serviceRollResultNotificationRequest)
+            .put(ServiceReconfigureBulk.class, this::serviceReconfigureBulk)
+            .put(ServiceReconfigureResultNotificationRequest.class, this::serviceReconfigureResultNotificationRequest)
+            .put(ServiceRestorationResultNotificationRequest.class, this::serviceRestorationResultNotificationRequest)
+            .put(ServiceReversionResultNotificationRequest.class, this::serviceReversionResultNotificationRequest)
+            .put(ServiceRerouteConfirmResultNotificationRequest.class,
+                this::serviceRerouteConfirmResultNotificationRequest)
+            .put(OpticalTunnelCreate.class, this::opticalTunnelCreate)
+            .put(OpticalTunnelRequestCancel.class, this::opticalTunnelRequestCancel)
+            .put(AddOpenroadmOperationalModesToCatalog.class, this::addOpenroadmOperationalModesToCatalog)
+            .put(AddSpecificOperationalModesToCatalog.class, this::addSpecificOperationalModesToCatalog)
+            .put(ServiceSrlgGet.class, this::serviceSrlgGet)
+            .put(EndTerminalPerformanceInfoRequest.class, this::endTerminalPerformanceInfoRequest)
+            .put(EndTerminalActivationRequest.class, this::endTerminalActivationRequest)
+            .put(EndTerminalDeactivationRequest.class, this::endTerminalDeactivationRequest)
+            .put(EndTerminalPowerControl.class, this::endTerminalPowerControl)
+            .build();
+    }
 }
 
index 9580550a077cb9f572c33986380e3e966308434d..c30e7aba14dbbfd25578c976a52e37a75a49819e 100644 (file)
@@ -13,7 +13,6 @@ 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.service.ServiceDataStoreOperations;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TransportpceNetworkmodelListener;
@@ -23,7 +22,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OrgOpen
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceList;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.Services;
 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;
@@ -49,12 +47,10 @@ public class ServicehandlerProvider {
     private ListenerRegistration<DataTreeChangeListener<Services>> serviceDataTreeChangeListenerRegistration;
     private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
     private ListenerRegistration<TransportpceNetworkmodelListener> networkmodellistenerRegistration;
-    private ObjectRegistration<OrgOpenroadmServiceService> rpcRegistration;
     private ServiceDataStoreOperations serviceDataStoreOperations;
 
     @Activate
     public ServicehandlerProvider(@Reference final DataBroker dataBroker,
-            @Reference RpcProviderService rpcProviderService,
             @Reference NotificationService notificationService,
             @Reference ServiceDataStoreOperations serviceDataStoreOperations,
             @Reference TransportpcePceListener pceListenerImpl,
@@ -70,8 +66,6 @@ public class ServicehandlerProvider {
         networkmodellistenerRegistration = notificationService.registerNotificationListener(networkModelListenerImpl);
         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");
     }
@@ -86,6 +80,5 @@ public class ServicehandlerProvider {
         serviceDataTreeChangeListenerRegistration.close();
         rendererlistenerRegistration.close();
         networkmodellistenerRegistration.close();
-        rpcRegistration.close();
     }
 }
\ No newline at end of file
index 0c5277d06e69b82ce588fef4474c77a6e522ca09..be7eb840fd5df1787586695456433a7cd0dea54b 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.transportpce.servicehandler.impl;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
 
@@ -29,6 +31,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
@@ -92,6 +95,8 @@ import org.opendaylight.yangtools.yang.common.Uint32;
 @ExtendWith(MockitoExtension.class)
 public class ServicehandlerImplTest extends AbstractTest {
 
+    @Mock
+    private RpcProviderService rpcProviderService;
     @Mock
     private PathComputationService pathComputationService;
     @Mock
@@ -133,10 +138,19 @@ public class ServicehandlerImplTest extends AbstractTest {
         pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
     }
 
+    @Test
+    void testRpcRegistration() {
+        new ServicehandlerImpl(rpcProviderService,
+            pathComputationService, rendererServiceOperations, notificationPublishService,
+            pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+            serviceDataStoreOperations, catalogDataStoreOperations);
+        verify(rpcProviderService, times(1)).registerRpcImplementations(any());
+    }
+
     @Test
     void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<ServiceCreateOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -157,7 +171,7 @@ public class ServicehandlerImplTest extends AbstractTest {
                                 .setServiceName(serviceCreateInput.getServiceName())
                                 .build()));
         ListenableFuture<RpcResult<ServiceCreateOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDSOperations, catalogDataStoreOperations)
@@ -173,7 +187,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
         when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
         ListenableFuture<RpcResult<ServiceCreateOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -188,7 +202,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -208,7 +222,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -225,7 +239,7 @@ public class ServicehandlerImplTest extends AbstractTest {
         when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
         serviceDataStoreOperations.createService(serviceCreateInput);
         ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -239,7 +253,7 @@ public class ServicehandlerImplTest extends AbstractTest {
 
     @Test
     void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
-        ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
+        ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(rpcProviderService, pathComputationService,
                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
                 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
@@ -256,7 +270,7 @@ public class ServicehandlerImplTest extends AbstractTest {
             throws ExecutionException, InterruptedException {
         when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -271,7 +285,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -285,7 +299,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
         //action -> service reconfigure
         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -303,7 +317,7 @@ public class ServicehandlerImplTest extends AbstractTest {
         //service reconfigure test action
         //ServiceReconfigureInput is created with the same service information that is created before
         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -315,7 +329,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -330,7 +344,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
         //action -> service restore
         ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -348,7 +362,7 @@ public class ServicehandlerImplTest extends AbstractTest {
         //service Restoration test action
         //ServiceRestorationInput is created with the same service information that is created before
         ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -360,7 +374,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -378,7 +392,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
         //action -> service reconfigure
         ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -449,7 +463,7 @@ public class ServicehandlerImplTest extends AbstractTest {
                         .build());
         serviceDataStoreOperations.createService(serviceCreateInput);
         ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -464,7 +478,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -485,7 +499,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -504,7 +518,7 @@ public class ServicehandlerImplTest extends AbstractTest {
         TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
         serviceDataStoreOperations.createTempService(createInput, pathDescription);
         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
-                new ServicehandlerImpl(
+                new ServicehandlerImpl(rpcProviderService,
                         pathComputationService, rendererServiceOperations, notificationPublishService,
                         pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                         serviceDataStoreOperations, catalogDataStoreOperations)
@@ -519,7 +533,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Test
     void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -541,7 +555,7 @@ public class ServicehandlerImplTest extends AbstractTest {
                         .setCommonId("bad_commonId")
                         .build()));
         ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDSOperations, catalogDataStoreOperations)
@@ -561,7 +575,7 @@ public class ServicehandlerImplTest extends AbstractTest {
             throws ExecutionException, InterruptedException {
         when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
         ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -577,7 +591,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
             throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -591,7 +605,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
             throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -605,7 +619,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
             throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
@@ -619,7 +633,7 @@ public class ServicehandlerImplTest extends AbstractTest {
     public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
             throws ExecutionException, InterruptedException {
         ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
-            new ServicehandlerImpl(
+            new ServicehandlerImpl(rpcProviderService,
                     pathComputationService, rendererServiceOperations, notificationPublishService,
                     pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                     serviceDataStoreOperations, catalogDataStoreOperations)
index ae3734ae327a9f9e3a1d91704b6fb159129f2be1..99e6c399e5c83c1d64b9b01e3801fc4e86719eb3 100644 (file)
@@ -18,7 +18,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 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.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TransportpceNetworkmodelListener;
@@ -33,8 +32,6 @@ public class ServicehandlerProviderTest extends AbstractTest {
     @Mock
     DataBroker dataBroker;
     @Mock
-    RpcProviderService rpcProviderRegistry;
-    @Mock
     ServiceDataStoreOperations serviceDataStoreOperations;
     @Mock
     TransportpcePceListener pceListenerImpl;
@@ -51,11 +48,10 @@ public class ServicehandlerProviderTest extends AbstractTest {
 
     @Test
     void testInitRegisterServiceHandlerToRpcRegistry() {
-        new ServicehandlerProvider(dataBroker, rpcProviderRegistry, getNotificationService() ,
+        new ServicehandlerProvider(dataBroker, getNotificationService() ,
                 serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                 notificationPublishService, servicehandler, serviceListener);
 
-        verify(rpcProviderRegistry, times(1)).registerRpcImplementation(any(), any(OrgOpenroadmServiceService.class));
         verify(dataBroker, times(1)).registerDataTreeChangeListener(any(), any());
     }
 }
\ No newline at end of file
index 3ef19d9df90692500b2b1849cfa7d591fffb8d84..70a9adcb392808f36f877f2d889c9b10d29f6f69 100644 (file)
@@ -26,6 +26,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.InstanceIdentifiers;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
@@ -86,6 +87,8 @@ public class TapiConnectivityImplTest extends AbstractTest {
     private NetworkListener networkModelListenerImpl;
     @Mock
     public CatalogDataStoreOperations catalogDataStoreOperations;
+    @Mock
+    private RpcProviderService rpcProviderService;
 
     private static final Logger LOG = LoggerFactory.getLogger(TapiConnectivityImplTest.class);
     private static ServiceDataStoreOperations serviceDataStoreOperations;
@@ -129,7 +132,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
 
     @Test
     void createConnServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
-        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
             rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
@@ -154,7 +157,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
     @Test
     void createConnServiceShouldBeSuccessfulWhenPerformPCESuccessful()
             throws ExecutionException, InterruptedException {
-        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
             rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
@@ -180,7 +183,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
 
     @Test
     void deleteConnServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
-        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
             rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
@@ -205,7 +208,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
     @Test
     void deleteConnServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
         DeleteConnectivityServiceInput input = TapiConnectivityDataUtils.buildConnServiceDeleteInput1();
-        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
             rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
@@ -230,7 +233,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
     void deleteConnServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
         when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
 
-        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(pathComputationService,
+        OrgOpenroadmServiceService serviceHandler = new ServicehandlerImpl(rpcProviderService, pathComputationService,
             rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);