Service-restoration implementation
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / impl / ServiceHandlerImplTest.java
index cccc875a502d35c96ab14e3139f49ddba0cf0356..6c06e45c21ad222ba670b840c240480268b0d44c 100644 (file)
@@ -8,7 +8,9 @@
 package org.opendaylight.transportpce.servicehandler.impl;
 
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.verify;
+
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -17,7 +19,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -26,25 +30,34 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.transportpce.common.OperationResult;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
-import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
-import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
 import org.opendaylight.transportpce.pce.utils.PceTestData;
 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
+import org.opendaylight.transportpce.servicehandler.ServiceInput;
+import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
+import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
+import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
+import org.opendaylight.transportpce.servicehandler.stub.StubPceServiceOperations;
 import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
+import org.opendaylight.transportpce.servicehandler.utils.MockedNotificationServiceWrapper;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.TransportpcePceListener;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.TransportpceRendererListener;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceNotificationTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
@@ -62,13 +75,21 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -76,56 +97,97 @@ import org.slf4j.LoggerFactory;
 public class ServiceHandlerImplTest extends AbstractTest {
 
     private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerImplTest.class);
+    private static final int NUMBER_OF_THREADS = 4;
 
     private PathComputationService pathComputationService;
     private RendererServiceOperations rendererServiceOperations;
     private ServicehandlerImpl serviceHandler;
+    private PceListenerImpl pceListenerImpl;
+    private RendererListenerImpl rendererListenerImpl;
+    private ListeningExecutorService executor;
+    private NotificationPublishService notificationPublishService;
+    private NotificationService notificationService;
+    private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
+    private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
+    private MockedNotificationServiceWrapper mockedNotificationServiceWrapper;
 
     @Mock
     private ServiceDataStoreOperations serviceDataStoreOperationsMock;
-
     @Mock
     private PCEServiceWrapper pceServiceWrapperMock;
-
+    @Mock
+    private RendererServiceWrapper rendererServiceWrapperMock;
+    @Mock
+    private PathComputationService pathComputationServiceMock;
     @Mock
     private RendererServiceOperations rendererServiceOperationsMock;
-
     @Mock
     private ComplianceCheckResult complianceCheckResultMock;
-
     @Mock
     private Optional<Services> servicesOptionalMock;
-
+    @Mock
+    private PceListenerImpl pceListenerImplMock;
+    @Mock
+    private RendererListenerImpl rendererListenerImplMock;
+    @Mock
+    private NotificationPublishService notificationPublishServiceMock;
+    @Mock
+    private NetworkModelWavelengthService networkModelWavelengthServiceMock;
     @InjectMocks
     private ServicehandlerImpl serviceHandlerImplMock;
 
     @Before
     public void setUp() {
         this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
-                this.rendererServiceOperations);
-        this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+                this.rendererServiceOperations, this.notificationPublishService, this.pceListenerImpl,
+                this.rendererListenerImpl, this.networkModelWavelengthServiceMock);
+        this.serviceHandlerImplMock =
+                new ServicehandlerImpl(getDataBroker(), this.pathComputationService, this.rendererServiceOperations,
+                        notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
         MockitoAnnotations.initMocks(this);
     }
 
     public ServiceHandlerImplTest() throws Exception {
-        NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
-        this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
+        this.mockedNotificationServiceWrapper = new MockedNotificationServiceWrapper(getNotificationPublishService());
+        this.notificationPublishService = this.mockedNotificationServiceWrapper.getMockedNotificationService();
+        this.notificationService = getNotificationService();
+        this.pathComputationService = new StubPceServiceOperations(notificationPublishService);
+        this.rendererServiceOperations = new StubRendererServiceOperations(this.networkModelWavelengthServiceMock,
+                getDataBroker(), notificationPublishService);
         PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
                 "topologyData/NW-simple-topology.xml");
-        this.rendererServiceOperations = new StubRendererServiceOperations(notificationPublishService);
+        this.pceListenerImpl =
+                new PceListenerImpl(rendererServiceOperations, pathComputationService, notificationPublishService,
+                        null);
+        this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
+        this.pceListenerImpl.setServiceReconfigure(false);
+        this.rendererListenerImpl =
+                new RendererListenerImpl(pathComputationServiceMock, notificationPublishService);
+        this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
+        this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
+        pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
+        rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
     }
 
+
+
     @Test
     public void testCreateServiceValid() throws ExecutionException, InterruptedException {
-
         ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
-
-        Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandler.serviceCreate(serviceInput);
+        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
+                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
+        PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
+                PceTestData.getPCE_simpletopology_test1_result((long) 5))
+                        .setConfigurationResponseCommon(configurationResponseCommon).build();
+        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
+            .thenReturn(pathComputationRequestOutput);
+        Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
         Assert.assertNotNull(output0);
         Assert.assertTrue(output0.get().isSuccessful());
-        Assert.assertEquals(output0.get().getResult(),
-                ModelMappingUtils.createCreateServiceReply(serviceInput, ResponseCodes.FINAL_ACK_YES,
-                        "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get().getResult());
+        Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
+                ResponseCodes.FINAL_ACK_NO,"PCE calculation in progress", ResponseCodes.RESPONSE_OK)
+                        .get().getResult());
         Assert.assertEquals(0, output0.get().getErrors().size());
     }
 
@@ -136,7 +198,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         emptyServiceNameInput = builtInput.setServiceName("").build();
         Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
                 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
-                        "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+                        "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+                        .getResult());
     }
 
     @Test
@@ -146,7 +209,30 @@ public class ServiceHandlerImplTest extends AbstractTest {
         nullServiceNameInput = builtInput.setServiceName(null).build();
         Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
                 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
-                        "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
+                        "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+                        .getResult());
+    }
+
+    @Test
+    public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+        TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+        TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+        emptyServiceNameInput = builtInput.setCommonId("").build();
+        Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+                ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+                        "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
+                        .getResult());
+    }
+
+    @Test
+    public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+        TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
+        TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
+        emptyServiceNameInput = builtInput.setCommonId(null).build();
+        Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
+                ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
+                                "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
+                        .get().getResult());
     }
 
     @Test
@@ -252,7 +338,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
 
     @Test
     public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
-        ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+        ServicehandlerImpl servicehandler =
+                new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
         ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
         notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
@@ -265,7 +352,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
 
     @Test
     public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
-        ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+        ServicehandlerImpl servicehandler =
+                new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
         ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
         notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
@@ -429,7 +517,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         txDirectionBuilder.setLgx(lgx);
         serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
-        ServicehandlerImpl serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+        this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
+                null, null);
         return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
                 .getResult();
     }
@@ -500,205 +589,16 @@ public class ServiceHandlerImplTest extends AbstractTest {
     @Test
     public void createServiceHandlerResponseCodesNotPassed() throws ExecutionException, InterruptedException {
         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
-
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failed").build();
-        PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
-                PceTestData.getPCE_simpletopology_test1_result((long) 5))
-                        .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
-                .thenReturn(pathComputationRequestOutput);
-        ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
-        verify(this.pceServiceWrapperMock).performPCE(serviceCreateInput, true);
-    }
-
-    @Test
-    public void createServiceHandlerOperationResultNotPassed() throws ExecutionException, InterruptedException {
-        ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
-                PceTestData.getPCE_simpletopology_test1_result((long) 5))
-                        .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
-                .thenReturn(pathComputationRequestOutput);
-        Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class)))
-                .thenReturn(OperationResult.failed(
-                        "Failed to create service " + serviceCreateInput.getServiceName() + " to Service List"));
-        ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
-        verify(this.serviceDataStoreOperationsMock).createService(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class));
-    }
-
-    @Test
-    public void createServiceHandlerOperationServicePathSaveResultNotPassed()
-            throws ExecutionException, InterruptedException {
-        ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
+                .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("PCE calculation failed").build();
         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
                         .setConfigurationResponseCommon(configurationResponseCommon).build();
         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
                 .thenReturn(pathComputationRequestOutput);
-        Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class)))
-                .thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
-                        + " to ServicePath List"));
         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
-        verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class));
-    }
-
-    @Test
-    public void createServiceHandlerModifyServicePassed() throws ExecutionException, InterruptedException {
-        ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
-                PceTestData.getPCE_simpletopology_test1_result((long) 5))
-                        .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
-                .thenReturn(pathComputationRequestOutput);
-        Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
-
-        Mockito.when(
-                this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
-                .thenReturn(new ServiceImplementationRequestOutputBuilder()
-                        .setConfigurationResponseCommon(configurationResponseCommon2).build());
-        Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
-                State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
-        ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
-        verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
-                State.InService);
-    }
-
-    @Test
-    public void createServiceHandlerModifyServiceNotPassed() throws ExecutionException, InterruptedException {
-        ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
-                PceTestData.getPCE_simpletopology_test1_result((long) 5))
-                        .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
-                .thenReturn(pathComputationRequestOutput);
-        Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
-
-        Mockito.when(
-                this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
-                .thenReturn(new ServiceImplementationRequestOutputBuilder()
-                        .setConfigurationResponseCommon(configurationResponseCommon2).build());
-        Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
-                State.InService, State.InService)).thenReturn(OperationResult.failed("failure"));
-        ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
-        verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
-                State.InService);
-    }
-
-    @Test
-    public void createServiceHandlerServiceImplementationNotPassed() throws ExecutionException, InterruptedException {
-        ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
-                PceTestData.getPCE_simpletopology_test1_result((long) 5))
-                        .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
-                .thenReturn(pathComputationRequestOutput);
-        Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
-
-        Mockito.when(
-                this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
-                .thenReturn(new ServiceImplementationRequestOutputBuilder()
-                        .setConfigurationResponseCommon(configurationResponseCommon2).build());
-        Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
-                .thenReturn(OperationResult.ok("successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
-                .thenReturn(OperationResult.ok("successful"));
-        ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
-        verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
-        verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
-    }
-
-    @Test
-    public void createServiceHandlerServiceImplementationNotPassed2() throws ExecutionException, InterruptedException {
-        ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
-                PceTestData.getPCE_simpletopology_test1_result((long) 5))
-                        .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
-                .thenReturn(pathComputationRequestOutput);
-        Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
-                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
-        ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
-
-        Mockito.when(
-                this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
-                .thenReturn(new ServiceImplementationRequestOutputBuilder()
-                        .setConfigurationResponseCommon(configurationResponseCommon2).build());
-        Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
-                .thenReturn(OperationResult.failed("successful"));
-        Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
-                .thenReturn(OperationResult.failed("successful"));
-        ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
-        verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
-        verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
     }
 
     private ServiceCreateOutput getRxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
@@ -712,7 +612,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         rxDirectionBuilder.setLgx(lgx);
         serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
-        ServicehandlerImpl serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+        this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
+                null, null);
         return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
                 .getResult();
     }
@@ -747,6 +648,28 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
     }
 
+    @Test
+    public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+        serviceDeleteInput = builder.setCommonId("").build();
+        TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+                ResponseCodes.FINAL_ACK_YES);
+        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+    }
+
+    @Test
+    public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
+        serviceDeleteInput = builder.setCommonId(null).build();
+        TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
+        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+                ResponseCodes.FINAL_ACK_YES);
+        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
+    }
+
     @Test
     public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
@@ -854,144 +777,177 @@ public class ServiceHandlerImplTest extends AbstractTest {
     }
 
     @Test
-    public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
-
-        ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
-        Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
-        Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteInput input = ModelMappingUtils
-                .createServiceDeleteInput(serviceDeleteInput);
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("success").build();
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
-                .servicepath.rev170426.ServiceDeleteOutputBuilder()
-                .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
-        ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
+    public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
+        TempServiceDeleteOutput result =
+                this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
                 ResponseCodes.FINAL_ACK_YES);
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
     }
 
     @Test
-    public void deleteServicePathNotPassed() throws ExecutionException, InterruptedException {
-
-        ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
-        Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
-        Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteInput input = ModelMappingUtils
-                .createServiceDeleteInput(serviceDeleteInput);
-        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
-                .servicepath.rev170426.ServiceDeleteOutputBuilder()
-                .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
-        Mockito.when(this.serviceDataStoreOperationsMock
-                .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
-                .thenReturn(OperationResult.failed("failed"));
-        Mockito.when(this.serviceDataStoreOperationsMock
-                .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
-                .thenReturn(OperationResult.failed("failed"));
-        ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
-        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
-    }
-
-    @Test
-    public void deleteServiceOperationNotPassed() throws ExecutionException, InterruptedException {
-
+    public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteInput input = ModelMappingUtils
-                .createServiceDeleteInput(serviceDeleteInput);
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(serviceDeleteInput));
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
-                .servicepath.rev170426.ServiceDeleteOutputBuilder()
+                .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("Renderer service delete failed !")
+                .build();
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
                 .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
-        Mockito.when(this.serviceDataStoreOperationsMock
-                .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
-                .thenReturn(OperationResult.ok("success"));
-        Mockito.when(this.serviceDataStoreOperationsMock
-                .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
-                .thenReturn(OperationResult.ok("success"));
+        Mockito.when(this.rendererServiceWrapperMock.performRenderer(input,
+                ServiceNotificationTypes.ServiceDeleteResult)).thenReturn(output);
         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
                 ResponseCodes.FINAL_ACK_YES);
-        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
+        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
     }
 
     @Test
     public void deleteServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
-
         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteInput input = ModelMappingUtils
-                .createServiceDeleteInput(serviceDeleteInput);
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
+                    new ServiceInput(serviceDeleteInput));
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
-                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
-                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
-        org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
-            .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
-                .servicepath.rev170426.ServiceDeleteOutputBuilder()
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
+                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress")
+                .build();
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
+                .rev171017.ServiceDeleteOutputBuilder()
                 .setConfigurationResponseCommon(configurationResponseCommon).build();
-        Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
-        Mockito.when(this.serviceDataStoreOperationsMock
-                .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
-                .thenReturn(OperationResult.ok("success"));
-        Mockito.when(this.serviceDataStoreOperationsMock
-                .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
-                .thenReturn(OperationResult.ok("success"));
+        Mockito.when(
+                this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
+                .thenReturn(output);
         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
-                ResponseCodes.FINAL_ACK_YES);
+                ResponseCodes.FINAL_ACK_NO);
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
     }
 
     @Test
-    public void rerouteServiceIsNotePresent() throws ExecutionException, InterruptedException {
-
+    public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
         ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
         ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
         Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
-        Assert.assertEquals(result.getStatusMessage(), "Failure");
+        Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
 
     }
 
     @Test
     public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
-
-        ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
-        ServiceCreateOutput createOutput = this.serviceHandler.serviceCreate(createInput).get().getResult();
-        ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
-        ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
+        ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
+        ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
+        Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null);
+        Optional<Services> service = Optional.of(serviceMock);
+        Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
+        ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
+                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
+                .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress")
+                .build();
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+            .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
+                .rev171017.ServiceDeleteOutputBuilder()
+                .setConfigurationResponseCommon(configurationResponseCommon).build();
+        Mockito.when(
+                this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
+                .thenReturn(output);
+        ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
         Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
                 result.getStatus());
-        Assert.assertEquals("Success", result.getStatusMessage());
+        Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());
+    }
 
+    @Test
+    public void reConfigureServiceIfserviceNotPresent() throws ExecutionException, InterruptedException {
+        ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
+        ServiceReconfigureOutput result = this.serviceHandler.serviceReconfigure(input).get().getResult();
+        Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
+        Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
+    }
+
+    @Test
+    public void reConfigureServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
+        ServiceReconfigureInput serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
+        Services serviceMock = ModelMappingUtils.mappingServices(null, serviceReconfigureInput);
+        Optional<Services> service = Optional.of(serviceMock);
+        Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput input =
+                ModelMappingUtils.createServiceDeleteInput(serviceReconfigureInput);
+        ConfigurationResponseCommon configurationResponseCommon =
+                new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
+                        .setRequestId("1").setResponseCode(ResponseCodes.RESPONSE_OK)
+                        .setResponseMessage("Renderer service delete in progress").build();
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput output =
+                new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+                    .ServiceDeleteOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon).build();
+        Mockito.when(
+                this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
+                .thenReturn(output);
+        ServiceReconfigureOutput result =
+                this.serviceHandlerImplMock.serviceReconfigure(serviceReconfigureInput).get().getResult();
+        Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
+                result.getStatus());
+        Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());
     }
 
-    /*@Test(expected = ReadFailedException.class)
-    public void rerouteServiceThrowsException() throws ReadFailedException, InterruptedException, ExecutionException{
-        ServiceCreateInput createInput = buildServiceCreateInput();
-        ServiceCreateOutput createOutput = serviceHandler.serviceCreate(createInput).get().getResult();
-        ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
-        Mockito.when(dataStoreService.checkedGet()).thenThrow(InterruptedException.class);
-        ServiceRerouteOutput result = serviceHandler.serviceReroute(input).get().getResult();
-    }*/
+    @Test
+    public void restorationServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
+        ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
+        ServiceRestorationOutput result = this.serviceHandler.serviceRestoration(input).get().getResult();
+        Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
+        Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
+    }
+
+    @Test
+    public void restorationServiceIfServiceNotDown() throws ExecutionException, InterruptedException {
+        ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
+        Services serviceMock = ModelMappingUtils.mappingServices(ServiceDataUtils.buildServiceCreateInput(), null);
+        ServicesBuilder builder = new ServicesBuilder(serviceMock).setAdministrativeState(State.InService)
+                .setOperationalState(State.InService);
+        Optional<Services> service = Optional.of(builder.build());
+        Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
+        ServiceRestorationOutput result = this.serviceHandlerImplMock.serviceRestoration(input).get().getResult();
+        Assert.assertEquals(RpcStatus.Failed, result.getStatus());
+        Assert.assertEquals("Service 'service 1' is in 'inService' state", result.getStatusMessage());
+    }
+
+    @Test
+    public void restorationServiceIfServicePresentAndDown() throws ExecutionException, InterruptedException {
+        ServiceRestorationInput serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
+        Services serviceMock = ModelMappingUtils.mappingServices(ServiceDataUtils.buildServiceCreateInput(), null);
+        ServicesBuilder builder = new ServicesBuilder(serviceMock).setAdministrativeState(State.OutOfService)
+                .setOperationalState(State.OutOfService);
+        Optional<Services> service = Optional.of(builder.build());
+        Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput input =
+                ModelMappingUtils.createServiceDeleteInput(serviceRestorationInput, serviceMock);
+        ConfigurationResponseCommon configurationResponseCommon =
+                new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
+                        .setRequestId("1").setResponseCode(ResponseCodes.RESPONSE_OK)
+                        .setResponseMessage("Renderer service delete in progress").build();
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput output =
+                new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
+                    .ServiceDeleteOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon).build();
+        Mockito.when(
+                this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
+                .thenReturn(output);
+        ServiceRestorationOutput result =
+                this.serviceHandlerImplMock.serviceRestoration(serviceRestorationInput).get().getResult();
+        Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
+                result.getStatus());
+        Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());
+    }
 }