8ff5eebc7fa843fde7355efee2de3d3c13bb1ec6
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / impl / ServicehandlerImplTest.java
1 /*
2  * Copyright © 2019 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.servicehandler.impl;
9
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.mock;
12 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
13
14 import com.google.common.util.concurrent.Futures;
15 import com.google.common.util.concurrent.ListenableFuture;
16 import com.google.common.util.concurrent.ListeningExecutorService;
17 import com.google.common.util.concurrent.MoreExecutors;
18 import java.util.Optional;
19 import java.util.concurrent.CountDownLatch;
20 import java.util.concurrent.ExecutionException;
21 import java.util.concurrent.Executors;
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.mockito.Mock;
26 import org.mockito.Mockito;
27 import org.mockito.MockitoAnnotations;
28 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
29 import org.opendaylight.transportpce.common.ResponseCodes;
30 import org.opendaylight.transportpce.pce.service.PathComputationService;
31 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
32 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
33 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
34 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
35 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
36 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
37 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
38 import org.opendaylight.transportpce.test.AbstractTest;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
64 import org.opendaylight.yangtools.yang.common.RpcResult;
65
66 public class ServicehandlerImplTest extends AbstractTest {
67
68     @Mock
69     private PathComputationService pathComputationService;
70
71     @Mock
72     private RendererServiceOperations rendererServiceOperations;
73
74     @Mock
75     private NotificationPublishService notificationPublishService;
76
77     @Mock
78     private PceListenerImpl pceListenerImpl;
79
80     @Mock
81     private RendererListenerImpl rendererListenerImpl;
82
83     @Mock
84     private NetworkModelListenerImpl networkModelListenerImpl;
85
86     private ServiceDataStoreOperations serviceDataStoreOperations;
87     private ServiceCreateInput serviceCreateInput;
88     private ServiceDeleteInput serviceDeleteInput;
89     private ServiceReconfigureInput serviceReconfigureInput;
90     private ServiceRestorationInput serviceRestorationInput;
91     private ServiceRerouteInput serviceRerouteInput;
92     private ListeningExecutorService executorService;
93     private CountDownLatch endSignal;
94     private static final int NUM_THREADS = 5;
95
96     @Before
97     public void setUp() {
98         executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
99         endSignal = new CountDownLatch(1);
100         MockitoAnnotations.openMocks(this);
101         this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
102         serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
103         serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
104         serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
105         serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
106         serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
107     }
108
109     @Test
110     public void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
111         ServicehandlerImpl servicehandlerImpl =
112                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
113                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
114                         serviceDataStoreOperations);
115         ListenableFuture<RpcResult<ServiceCreateOutput>> result =
116                 servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
117         result.addListener(() -> endSignal.countDown(), executorService);
118
119         endSignal.await();
120         Assert.assertEquals(
121                 ResponseCodes.RESPONSE_FAILED,
122                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
123     }
124
125     @Test
126     public void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException,
127             InterruptedException {
128         final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
129         Mockito.when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
130                 .thenReturn(Optional.of(
131                         new ServicesBuilder()
132                                 .setServiceName(serviceCreateInput.getServiceName())
133                                 .build()));
134         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
135                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
136                 networkModelListenerImpl, serviceDSOperations);
137         ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
138         result.addListener(() -> endSignal.countDown(), executorService);
139
140         endSignal.await();
141         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
142                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
143     }
144
145     @Test
146     public void createServiceShouldBeSuccessfulWhenPerformPCESuccessful()
147             throws ExecutionException, InterruptedException {
148         Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
149         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
150                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
151                 networkModelListenerImpl, serviceDataStoreOperations);
152         ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
153         result.addListener(() -> endSignal.countDown(), executorService);
154
155         endSignal.await();
156         Assert.assertEquals(
157                 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
158     }
159
160     @Test
161     public void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
162         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
163                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
164                 networkModelListenerImpl, serviceDataStoreOperations);
165         ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(
166                 new ServiceDeleteInputBuilder()
167                         .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
168                                 .setServiceName("")
169                                 .build())
170                         .build());
171         result.addListener(() -> endSignal.countDown(), executorService);
172
173         endSignal.await();
174         Assert.assertEquals(
175                 ResponseCodes.RESPONSE_FAILED,
176                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
177     }
178
179     @Test
180     public void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
181         ServicehandlerImpl servicehandlerImpl =
182                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
183                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
184                         serviceDataStoreOperations);
185         ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
186         result.addListener(() -> endSignal.countDown(), executorService);
187
188         endSignal.await();
189         Assert.assertEquals(
190                 ResponseCodes.RESPONSE_FAILED,
191                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
192     }
193
194     @Test
195     public void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
196         Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
197         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
198                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
199                 networkModelListenerImpl, serviceDataStoreOperations);
200         serviceDataStoreOperations.createService(serviceCreateInput);
201         ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
202         result.addListener(() -> endSignal.countDown(), executorService);
203
204         endSignal.await();
205         Assert.assertEquals(
206                 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
207     }
208
209
210     @Test
211     public void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
212         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
213                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
214                 networkModelListenerImpl, serviceDataStoreOperations);
215         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
216                 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
217         result.addListener(() -> endSignal.countDown(), executorService);
218
219         endSignal.await();
220         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
221                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
222     }
223
224     @Test
225     public void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
226             throws ExecutionException, InterruptedException {
227         Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
228         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
229                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
230                 networkModelListenerImpl, serviceDataStoreOperations);
231         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
232                 servicehandlerImpl.serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
233         result.addListener(() -> endSignal.countDown(), executorService);
234
235         endSignal.await();
236         Assert.assertEquals(
237                 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
238     }
239
240     @Test
241     public void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
242         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
243                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
244                 networkModelListenerImpl, serviceDataStoreOperations);
245         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
246                 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
247         result.addListener(() -> endSignal.countDown(), executorService);
248
249         endSignal.await();
250     }
251
252
253     @Test
254     public void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
255         //action -> service reconfigure
256         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
257                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
258                 networkModelListenerImpl, serviceDataStoreOperations);
259         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
260                 serviceReconfigureInput);
261
262         result.addListener(() -> endSignal.countDown(), executorService);
263
264         endSignal.await();
265     }
266
267     @Test
268     public void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
269         // serviceReconfigure is calling service delete method in renderer
270         Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
271         //create service to reconfigure
272         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
273                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
274                 networkModelListenerImpl, serviceDataStoreOperations);
275         serviceDataStoreOperations.createService(serviceCreateInput);
276
277         //service reconfigure test action
278         //ServiceReconfigureInput is created with the same service information that is created before
279         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
280                 serviceReconfigureInput);
281         result.addListener(() -> endSignal.countDown(), executorService);
282
283         endSignal.await();
284     }
285
286     @Test
287     public void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
288         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
289                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
290                 networkModelListenerImpl, serviceDataStoreOperations);
291         ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
292                 servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
293         result.addListener(() -> endSignal.countDown(), executorService);
294
295         endSignal.await();
296     }
297
298
299     @Test
300     public void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
301         //action -> service restore
302         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
303                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
304                 networkModelListenerImpl, serviceDataStoreOperations);
305         ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
306                 serviceRestorationInput);
307
308         result.addListener(() -> endSignal.countDown(), executorService);
309
310         endSignal.await();
311     }
312
313     @Test
314     public void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
315         // serviceRestoration is calling service delete method in renderer
316         Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
317         //create service to restore
318         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
319                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
320                 networkModelListenerImpl, serviceDataStoreOperations);
321         serviceDataStoreOperations.createService(serviceCreateInput);
322
323         //service Restoration test action
324         //ServiceRestorationInput is created with the same service information that is created before
325         ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
326                 serviceRestorationInput);
327         result.addListener(() -> endSignal.countDown(), executorService);
328
329         endSignal.await();
330     }
331
332     @Test
333     public void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
334         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
335                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
336                 networkModelListenerImpl, serviceDataStoreOperations);
337         ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
338                 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
339         result.addListener(() -> endSignal.countDown(), executorService);
340
341         endSignal.await();
342     }
343
344     @Test
345     public void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
346         //action -> service reconfigure
347         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
348                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
349                 networkModelListenerImpl, serviceDataStoreOperations);
350         ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(
351                 serviceRerouteInput);
352
353         result.addListener(() -> endSignal.countDown(), executorService);
354
355         endSignal.await();
356     }
357
358     @Test
359     public void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
360         //create service to be rerouted later
361         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
362                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
363                 networkModelListenerImpl, serviceDataStoreOperations);
364         serviceDataStoreOperations.createService(serviceCreateInput);
365
366         //service reroute test action
367         //ServiceRerouteInput is created with the same service information that is created before
368         ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(
369                 serviceRerouteInput);
370         result.addListener(() -> endSignal.countDown(), executorService);
371
372         endSignal.await();
373     }
374
375     @Test
376     public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
377         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
378                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
379                 networkModelListenerImpl, serviceDataStoreOperations);
380         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
381                 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder().setCommonId("").build());
382         result.addListener(() -> endSignal.countDown(), executorService);
383
384         endSignal.await();
385
386         RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
387         Assert.assertEquals(
388                 ResponseCodes.RESPONSE_FAILED,
389                 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
390         Assert.assertEquals(
391                 LogMessages.SERVICE_NON_COMPLIANT,
392                 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
393     }
394
395     @Test
396     public void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
397         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
398                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
399                 networkModelListenerImpl, serviceDataStoreOperations);
400         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(
401                 ServiceDataUtils.buildTempServiceDeleteInput());
402         result.addListener(() -> endSignal.countDown(), executorService);
403
404         endSignal.await();
405         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
406                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
407     }
408
409     @Test
410     public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
411         Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
412
413         //create temp service to delete in the temp delete action
414         ServicehandlerImpl servicehandlerImpl =
415                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
416                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
417                         serviceDataStoreOperations);
418         TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
419         serviceDataStoreOperations.createTempService(createInput);
420
421         TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
422         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
423         result.addListener(() -> endSignal.countDown(), executorService);
424
425         endSignal.await();
426         Assert.assertEquals(
427                 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
428     }
429
430     @Test
431     public void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
432         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
433                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
434                 networkModelListenerImpl, serviceDataStoreOperations);
435         ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
436                 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
437         result.addListener(() -> endSignal.countDown(), executorService);
438
439         endSignal.await();
440         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
441                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
442     }
443
444
445     @Test
446     public void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
447             throws ExecutionException, InterruptedException {
448         Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
449
450         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
451                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
452                 networkModelListenerImpl, serviceDataStoreOperations);
453
454         ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(
455                 ServiceDataUtils.buildTempServiceCreateInput());
456         result.addListener(() -> endSignal.countDown(), executorService);
457
458         endSignal.await();
459         Assert.assertEquals(
460                 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
461     }
462
463 }