2 * Copyright © 2019 Orange, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.servicehandler.impl;
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import com.google.common.util.concurrent.ListeningExecutorService;
16 import com.google.common.util.concurrent.MoreExecutors;
17 import java.util.concurrent.CountDownLatch;
18 import java.util.concurrent.ExecutionException;
19 import java.util.concurrent.Executors;
20 import org.junit.Assert;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.mockito.Mock;
24 import org.mockito.Mockito;
25 import org.mockito.MockitoAnnotations;
26 import org.opendaylight.mdsal.binding.api.DataBroker;
27 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
28 import org.opendaylight.transportpce.common.ResponseCodes;
29 import org.opendaylight.transportpce.pce.service.PathComputationService;
30 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
31 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
32 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
33 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
34 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
35 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
36 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
37 import org.opendaylight.transportpce.test.AbstractTest;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev190531.RpcStatus;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateOutput;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInput;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInputBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteOutput;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckInputBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceFeasibilityCheckOutput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureInputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceReconfigureOutput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteInputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRerouteOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationInputBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceRestorationOutput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateInputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceCreateOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInputBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfoBuilder;
64 import org.opendaylight.yangtools.yang.common.RpcResult;
66 public class ServicehandlerImplTest extends AbstractTest {
69 private PathComputationService pathComputationService;
72 private RendererServiceOperations rendererServiceOperations;
75 private NotificationPublishService notificationPublishService;
78 private PceListenerImpl pceListenerImpl;
81 private RendererListenerImpl rendererListenerImpl;
84 private NetworkModelListenerImpl networkModelListenerImpl;
86 private ServiceDataStoreOperations serviceDataStoreOperations;
87 private ListeningExecutorService executorService;
88 private CountDownLatch endSignal;
89 private static final int NUM_THREADS = 5;
90 private boolean callbackRan;
94 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
95 endSignal = new CountDownLatch(1);
97 MockitoAnnotations.openMocks(this);
98 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
102 public void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
103 ServicehandlerImpl servicehandlerImpl =
104 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
105 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
106 serviceDataStoreOperations, "ServiceHandler");
107 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
108 servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
109 result.addListener(new Runnable() {
113 endSignal.countDown();
119 RpcResult<ServiceCreateOutput> rpcResult = result.get();
121 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
125 public void createServiceShouldBeSuccessfulWhenPreformPCESuccessful()
126 throws ExecutionException, InterruptedException {
127 ServiceCreateInput input = ServiceDataUtils.buildServiceCreateInput();
128 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
129 ServicehandlerImpl servicehandlerImpl =
130 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
131 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
132 serviceDataStoreOperations, "ServiceHandler");
133 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(input);
134 result.addListener(new Runnable() {
138 endSignal.countDown();
144 RpcResult<ServiceCreateOutput> rpcResult = result.get();
146 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
150 public void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
151 ServicehandlerImpl servicehandlerImpl =
152 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
153 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
154 serviceDataStoreOperations, "ServiceHandler");
155 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
156 servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder()
157 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("").build()).build());
158 result.addListener(new Runnable() {
162 endSignal.countDown();
168 RpcResult<ServiceDeleteOutput> rpcResult = result.get();
170 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
174 public void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
175 ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
176 ServicehandlerImpl servicehandlerImpl =
177 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
178 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
179 serviceDataStoreOperations, "ServiceHandler");
180 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(input);
181 result.addListener(new Runnable() {
185 endSignal.countDown();
191 RpcResult<ServiceDeleteOutput> rpcResult = result.get();
193 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
197 public void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
198 DataBroker dataBroker = getNewDataBroker();
199 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
200 ServicehandlerImpl servicehandlerImpl =
201 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
202 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
203 serviceDataStoreOperations, "ServiceHandler");
204 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
205 serviceDataStoreOperations.createService(createInput);
206 ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
207 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(input);
208 result.addListener(new Runnable() {
212 endSignal.countDown();
218 RpcResult<ServiceDeleteOutput> rpcResult = result.get();
220 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
225 public void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
226 ServicehandlerImpl servicehandlerImpl =
227 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
228 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
229 serviceDataStoreOperations, "ServiceHandler");
230 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
231 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
232 result.addListener(new Runnable() {
236 endSignal.countDown();
242 RpcResult<ServiceFeasibilityCheckOutput> rpcResult = result.get();
244 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
248 public void serviceFeasibilityCheckShouldBeSuccessfulWhenPreformPCESuccessful()
249 throws ExecutionException, InterruptedException {
250 ServiceFeasibilityCheckInput input = ServiceDataUtils.buildServiceFeasibilityCheckInput();
251 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
252 ServicehandlerImpl servicehandlerImpl =
253 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
254 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
255 serviceDataStoreOperations, "ServiceHandler");
256 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
257 servicehandlerImpl.serviceFeasibilityCheck(input);
258 result.addListener(new Runnable() {
262 endSignal.countDown();
268 RpcResult<ServiceFeasibilityCheckOutput> rpcResult = result.get();
270 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
274 public void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
275 ServicehandlerImpl servicehandlerImpl =
276 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
277 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
278 serviceDataStoreOperations, "ServiceHandler");
279 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
280 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
281 result.addListener(new Runnable() {
285 endSignal.countDown();
291 RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
293 RpcStatus.Failed, rpcResult.getResult().getStatus());
298 public void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
299 ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
301 //action -> service reconfigure
302 ServicehandlerImpl servicehandlerImpl =
303 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
304 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
305 serviceDataStoreOperations, "ServiceHandler");
306 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
308 result.addListener(new Runnable() {
312 endSignal.countDown();
318 RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
319 //ServiceReconfigureOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
321 RpcStatus.Failed, rpcResult.getResult().getStatus());
325 public void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
326 DataBroker dataBroker = getNewDataBroker();
329 // serviceReconfigure is calling service delete method in renderer
330 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
331 //create service to reconfigure
332 ServicehandlerImpl servicehandlerImpl =
333 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
334 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
335 serviceDataStoreOperations, "ServiceHandler");
336 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
337 serviceDataStoreOperations.createService(createInput);
339 //service reconfigure test action
340 ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
341 //ServiceReconfigureInput is created with the same service information that is created before
342 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
343 result.addListener(new Runnable() {
347 endSignal.countDown();
353 RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
355 RpcStatus.Successful, rpcResult.getResult().getStatus());
359 public void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
360 ServicehandlerImpl servicehandlerImpl =
361 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
362 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
363 serviceDataStoreOperations, "ServiceHandler");
364 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
365 servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
366 result.addListener(new Runnable() {
370 endSignal.countDown();
376 RpcResult<ServiceRestorationOutput> rpcResult = result.get();
378 RpcStatus.Failed, rpcResult.getResult().getStatus());
383 public void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
384 ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
386 //action -> service restore
387 ServicehandlerImpl servicehandlerImpl =
388 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
389 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
390 serviceDataStoreOperations, "ServiceHandler");
391 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
393 result.addListener(new Runnable() {
397 endSignal.countDown();
403 RpcResult<ServiceRestorationOutput> rpcResult = result.get();
404 //ServiceRestorationOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
406 RpcStatus.Failed, rpcResult.getResult().getStatus());
410 public void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
411 DataBroker dataBroker = getNewDataBroker();
414 // serviceRestoration is calling service delete method in renderer
415 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
416 //create service to restore
417 ServicehandlerImpl servicehandlerImpl =
418 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
419 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
420 serviceDataStoreOperations, "ServiceHandler");
421 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
422 serviceDataStoreOperations.createService(createInput);
424 //service Restoration test action
425 ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
426 //ServiceRestorationInput is created with the same service information that is created before
427 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
428 result.addListener(new Runnable() {
432 endSignal.countDown();
438 RpcResult<ServiceRestorationOutput> rpcResult = result.get();
440 RpcStatus.Successful, rpcResult.getResult().getStatus());
444 public void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
445 ServicehandlerImpl servicehandlerImpl =
446 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
447 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
448 serviceDataStoreOperations, "ServiceHandler");
449 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
450 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
451 result.addListener(new Runnable() {
455 endSignal.countDown();
461 RpcResult<ServiceRerouteOutput> rpcResult = result.get();
463 RpcStatus.Failed, rpcResult.getResult().getStatus());
467 public void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
468 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
470 //action -> service reconfigure
471 ServicehandlerImpl servicehandlerImpl =
472 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
473 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
474 serviceDataStoreOperations, "ServiceHandler");
475 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
477 result.addListener(new Runnable() {
481 endSignal.countDown();
487 RpcResult<ServiceRerouteOutput> rpcResult = result.get();
488 //ServiceRerouteOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
490 RpcStatus.Failed, rpcResult.getResult().getStatus());
494 public void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
495 DataBroker dataBroker = getNewDataBroker();
498 // serviceReroute is calling service delete method in renderer
499 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
500 //create service to be rerouted later
501 ServicehandlerImpl servicehandlerImpl =
502 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
503 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
504 serviceDataStoreOperations, "ServiceHandler");
505 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
506 serviceDataStoreOperations.createService(createInput);
508 //service reroute test action
509 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
510 //ServiceRerouteInput is created with the same service information that is created before
511 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
512 result.addListener(new Runnable() {
516 endSignal.countDown();
522 RpcResult<ServiceRerouteOutput> rpcResult = result.get();
524 RpcStatus.Successful, rpcResult.getResult().getStatus());
528 public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
529 ServicehandlerImpl servicehandlerImpl =
530 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
531 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
532 serviceDataStoreOperations, "ServiceHandler");
533 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
534 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder()
535 .setCommonId("").build());
536 result.addListener(new Runnable() {
540 endSignal.countDown();
546 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
548 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
550 LogMessages.SERVICE_NON_COMPLIANT,
551 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
555 public void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
556 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput();
557 ServicehandlerImpl servicehandlerImpl =
558 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
559 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
560 serviceDataStoreOperations, "ServiceHandler");
561 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
562 result.addListener(new Runnable() {
566 endSignal.countDown();
572 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
574 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
578 public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
579 DataBroker dataBroker = getNewDataBroker();
580 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
582 //create temp service to delete in the temp delete action
583 ServicehandlerImpl servicehandlerImpl =
584 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
585 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
586 serviceDataStoreOperations, "ServiceHandler");
587 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
588 serviceDataStoreOperations.createTempService(createInput);
591 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
592 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
593 result.addListener(new Runnable() {
597 endSignal.countDown();
603 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
605 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
609 public void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
610 ServicehandlerImpl servicehandlerImpl =
611 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
612 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
613 serviceDataStoreOperations, "ServiceHandler");
614 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
615 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
616 result.addListener(new Runnable() {
620 endSignal.countDown();
626 RpcResult<TempServiceCreateOutput> rpcResult = result.get();
628 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
633 public void tempServiceCreateShouldBeSuccessfulWhenPreformPCESuccessful()
634 throws ExecutionException, InterruptedException {
635 TempServiceCreateInput input = ServiceDataUtils.buildTempServiceCreateInput();
636 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
638 ServicehandlerImpl servicehandlerImpl =
639 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
640 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
641 serviceDataStoreOperations, "ServiceHandler");
643 ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(input);
644 result.addListener(new Runnable() {
648 endSignal.countDown();
654 RpcResult<TempServiceCreateOutput> rpcResult = result.get();
657 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());