Do not use RpcService in servicehandler module
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / impl / ServicehandlerImplTest.java
index cbe08616e479badaefbd93547be3fd82974a7b85..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;
@@ -46,43 +49,44 @@ import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
-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.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.ResourceBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
+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.ServiceFeasibilityCheckInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
+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.ServiceDeleteReqInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -91,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
@@ -104,6 +110,8 @@ public class ServicehandlerImplTest extends AbstractTest {
     @Mock
     private NetworkListener networkModelListenerImpl;
 
+    @Mock
+    private PathDescription pathDescription;
     private ServiceDataStoreOperations serviceDataStoreOperations;
     private CatalogDataStoreOperations catalogDataStoreOperations;
     private ServiceCreateInput serviceCreateInput;
@@ -127,12 +135,22 @@ public class ServicehandlerImplTest extends AbstractTest {
         serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
         serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
         serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
+        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)
@@ -153,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)
@@ -169,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)
@@ -184,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)
@@ -204,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)
@@ -221,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)
@@ -235,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 =
@@ -252,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)
@@ -267,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)
@@ -281,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)
@@ -299,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)
@@ -311,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)
@@ -326,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)
@@ -344,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)
@@ -356,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)
@@ -374,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)
@@ -445,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)
@@ -460,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)
@@ -481,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)
@@ -498,13 +516,13 @@ public class ServicehandlerImplTest extends AbstractTest {
         when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
         //create temp service to delete in the temp delete action
         TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
-        serviceDataStoreOperations.createTempService(createInput);
+        serviceDataStoreOperations.createTempService(createInput, pathDescription);
         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
-            new ServicehandlerImpl(
-                    pathComputationService, rendererServiceOperations, notificationPublishService,
-                    pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                    serviceDataStoreOperations, catalogDataStoreOperations)
-                .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
+                new ServicehandlerImpl(rpcProviderService,
+                        pathComputationService, rendererServiceOperations, notificationPublishService,
+                        pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+                        serviceDataStoreOperations, catalogDataStoreOperations)
+                    .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
         result.addListener(() -> endSignal.countDown(), executorService);
         endSignal.await();
         assertEquals(
@@ -515,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)
@@ -527,12 +545,37 @@ public class ServicehandlerImplTest extends AbstractTest {
             result.get().getResult().getConfigurationResponseCommon().getResponseCode());
     }
 
+    @Test
+    void tempServiceCreateShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
+        final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
+        when(serviceDSOperations.getTempService(any()))
+            .thenReturn(Optional.of(
+                    new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.list
+                            .ServicesBuilder()
+                        .setCommonId("bad_commonId")
+                        .build()));
+        ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
+            new ServicehandlerImpl(rpcProviderService,
+                    pathComputationService, rendererServiceOperations, notificationPublishService,
+                    pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+                    serviceDSOperations, catalogDataStoreOperations)
+                .tempServiceCreate(ServiceDataUtils.buildTempServiceCreateInput());
+        result.addListener(() -> endSignal.countDown(), executorService);
+        endSignal.await();
+        assertEquals(
+            ResponseCodes.RESPONSE_FAILED,
+            result.get().getResult().getConfigurationResponseCommon().getResponseCode());
+        assertEquals(
+            "Service 'Temp (commonId)' already exists in datastore",
+            result.get().getResult().getConfigurationResponseCommon().getResponseMessage());
+    }
+
     @Test
     void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
             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)
@@ -548,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)
@@ -562,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)
@@ -576,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)
@@ -590,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)