Update stubRenderer
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / impl / ServiceHandlerImplTest.java
index 2f81fc1f04eeb2940c6ec72d45671aa0eaa9f2d4..685a4fcc6cab135448c4924877b90d7e27625ed0 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,17 +34,22 @@ 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.service.PCEServiceWrapper;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
 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.renderer.rev171017.ServiceDeleteOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutputBuilder;
 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.configuration.response.common.ConfigurationResponseCommon;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
@@ -64,11 +70,15 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.Service
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
 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.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
+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.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -79,6 +89,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
 
     private PathComputationService pathComputationService;
     private RendererServiceOperations rendererServiceOperations;
+    private NetworkModelWavelengthService networkModelWavelengthService;
     private ServicehandlerImpl serviceHandler;
 
     @Mock
@@ -102,8 +113,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
     @Before
     public void setUp() {
         this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
-                this.rendererServiceOperations);
-        this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+                this.rendererServiceOperations, this.networkModelWavelengthService);
+        this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
         MockitoAnnotations.initMocks(this);
     }
 
@@ -112,7 +123,8 @@ public class ServiceHandlerImplTest extends AbstractTest {
         this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
         PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
                 "topologyData/NW-simple-topology.xml");
-        this.rendererServiceOperations = new StubRendererServiceOperations();
+        this.rendererServiceOperations =
+                new StubRendererServiceOperations(this.networkModelWavelengthService, getDataBroker());
     }
 
     @Test
@@ -130,7 +142,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
             .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),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
@@ -151,6 +163,40 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(0, output0.get().getErrors().size());
     }
 
+    @Test
+    public void createTempServiceHandlerServiceCreateValid() throws ExecutionException, InterruptedException {
+        TempServiceCreateInput serviceInput = ServiceDataUtils.buildTempServiceCreateInput();
+        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(serviceInput, true))
+                .thenReturn(pathComputationRequestOutput);
+        Mockito.when(this.serviceDataStoreOperationsMock.createTempService(any(TempServiceCreateInput.class),
+                any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.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.modifyTempService(serviceInput.getCommonId(), State.InService,
+                State.InService)).thenReturn(OperationResult.ok("successful"));
+        Future<RpcResult<TempServiceCreateOutput>> output0 =
+                this.serviceHandlerImplMock.tempServiceCreate(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(0, output0.get().getErrors().size());
+    }
+
     @Test
     public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
         ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
@@ -158,7 +204,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
@@ -168,7 +215,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
@@ -274,7 +344,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);
         ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
         notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
@@ -287,7 +358,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);
         ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
         notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
@@ -451,7 +523,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
         txDirectionBuilder.setLgx(lgx);
         serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
-        this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+        this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
         return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
                 .getResult();
     }
@@ -575,7 +647,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .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),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class)))
                 .thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
                         + " to ServicePath List"));
@@ -583,7 +655,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
                 ResponseCodes.FINAL_ACK_YES);
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
-        verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceCreateInput.class),
+        verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class));
     }
 
@@ -600,7 +672,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .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),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
@@ -633,7 +705,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .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),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
@@ -666,7 +738,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .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),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
@@ -701,7 +773,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
                 .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),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
@@ -734,7 +806,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
         rxDirectionBuilder.setLgx(lgx);
         serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
-        this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
+        this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
         return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
                 .getResult();
     }
@@ -769,6 +841,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();
@@ -875,21 +969,31 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
     }
 
+    @Test
+    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 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_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()
+        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);
         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
@@ -904,15 +1008,14 @@ public class ServiceHandlerImplTest extends AbstractTest {
         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()
+        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
@@ -933,15 +1036,14 @@ public class ServiceHandlerImplTest extends AbstractTest {
         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()
+        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
@@ -962,14 +1064,15 @@ public class ServiceHandlerImplTest extends AbstractTest {
         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()
+        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
@@ -984,6 +1087,38 @@ public class ServiceHandlerImplTest extends AbstractTest {
         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
     }
 
+    @Test
+    public void deleteTempServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
+
+        TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
+        Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
+            .Services> service = Optional.of(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
+                    .temp.service.list.ServicesBuilder().setCommonId("service 1").build());
+        Mockito.when(this.serviceDataStoreOperationsMock.getTempService("service 1")).thenReturn(service);
+        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.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.getCommonId()))
+                .thenReturn(OperationResult.ok("success"));
+        Mockito.when(this.serviceDataStoreOperationsMock
+                .deleteTempService(serviceDeleteInput.getCommonId()))
+                .thenReturn(OperationResult.ok("success"));
+        TempServiceDeleteOutput result = this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get()
+                .getResult();
+        Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
+                ResponseCodes.FINAL_ACK_YES);
+        Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
+    }
+
     @Test
     public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
 
@@ -1002,17 +1137,17 @@ public class ServiceHandlerImplTest extends AbstractTest {
         ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
 
         /** Mock RPC service-delete. */
-        Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null, null);
+        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.transportpce.b.c._interface.servicepath.rev170426
+        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("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()
+        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
@@ -1034,7 +1169,7 @@ public class ServiceHandlerImplTest extends AbstractTest {
             .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),
+        Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
         ConfigurationResponseCommon configurationResponseCommon3 = new ConfigurationResponseCommonBuilder()
                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")