Update ServicehandlerImplTest
[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         // serviceReroute is calling service delete method in renderer
361         Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
362         //create service to be rerouted later
363         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
364                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
365                 networkModelListenerImpl, serviceDataStoreOperations);
366         serviceDataStoreOperations.createService(serviceCreateInput);
367
368         //service reroute test action
369         //ServiceRerouteInput is created with the same service information that is created before
370         ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(
371                 serviceRerouteInput);
372         result.addListener(() -> endSignal.countDown(), executorService);
373
374         endSignal.await();
375     }
376
377     @Test
378     public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
379         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
380                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
381                 networkModelListenerImpl, serviceDataStoreOperations);
382         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
383                 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder().setCommonId("").build());
384         result.addListener(() -> endSignal.countDown(), executorService);
385
386         endSignal.await();
387
388         RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
389         Assert.assertEquals(
390                 ResponseCodes.RESPONSE_FAILED,
391                 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
392         Assert.assertEquals(
393                 LogMessages.SERVICE_NON_COMPLIANT,
394                 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
395     }
396
397     @Test
398     public void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
399         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
400                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
401                 networkModelListenerImpl, serviceDataStoreOperations);
402         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(
403                 ServiceDataUtils.buildTempServiceDeleteInput());
404         result.addListener(() -> endSignal.countDown(), executorService);
405
406         endSignal.await();
407         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
408                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
409     }
410
411     @Test
412     public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
413         Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
414
415         //create temp service to delete in the temp delete action
416         ServicehandlerImpl servicehandlerImpl =
417                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
418                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
419                         serviceDataStoreOperations);
420         TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
421         serviceDataStoreOperations.createTempService(createInput);
422
423         TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
424         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
425         result.addListener(() -> endSignal.countDown(), executorService);
426
427         endSignal.await();
428         Assert.assertEquals(
429                 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
430     }
431
432     @Test
433     public void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
434         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
435                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
436                 networkModelListenerImpl, serviceDataStoreOperations);
437         ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
438                 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
439         result.addListener(() -> endSignal.countDown(), executorService);
440
441         endSignal.await();
442         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
443                 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
444     }
445
446
447     @Test
448     public void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
449             throws ExecutionException, InterruptedException {
450         Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
451
452         ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
453                 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
454                 networkModelListenerImpl, serviceDataStoreOperations);
455
456         ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(
457                 ServiceDataUtils.buildTempServiceCreateInput());
458         result.addListener(() -> endSignal.countDown(), executorService);
459
460         endSignal.await();
461         Assert.assertEquals(
462                 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
463     }
464
465 }