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;
93 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
94 endSignal = new CountDownLatch(1);
95 MockitoAnnotations.openMocks(this);
96 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
100 public void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
101 ServicehandlerImpl servicehandlerImpl =
102 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
103 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
104 serviceDataStoreOperations);
105 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
106 servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
107 result.addListener(new Runnable() {
110 endSignal.countDown();
116 RpcResult<ServiceCreateOutput> rpcResult = result.get();
118 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
122 public void createServiceShouldBeSuccessfulWhenPreformPCESuccessful()
123 throws ExecutionException, InterruptedException {
124 ServiceCreateInput input = ServiceDataUtils.buildServiceCreateInput();
125 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
126 ServicehandlerImpl servicehandlerImpl =
127 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
128 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
129 serviceDataStoreOperations);
130 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(input);
131 result.addListener(new Runnable() {
134 endSignal.countDown();
140 RpcResult<ServiceCreateOutput> rpcResult = result.get();
142 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
146 public void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
147 ServicehandlerImpl servicehandlerImpl =
148 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
149 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
150 serviceDataStoreOperations);
151 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
152 servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder()
153 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("").build()).build());
154 result.addListener(new Runnable() {
157 endSignal.countDown();
163 RpcResult<ServiceDeleteOutput> rpcResult = result.get();
165 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
169 public void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
170 ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
171 ServicehandlerImpl servicehandlerImpl =
172 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
173 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
174 serviceDataStoreOperations);
175 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(input);
176 result.addListener(new Runnable() {
179 endSignal.countDown();
185 RpcResult<ServiceDeleteOutput> rpcResult = result.get();
187 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
191 public void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
192 DataBroker dataBroker = getNewDataBroker();
193 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
194 ServicehandlerImpl servicehandlerImpl =
195 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
196 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
197 serviceDataStoreOperations);
198 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
199 serviceDataStoreOperations.createService(createInput);
200 ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
201 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(input);
202 result.addListener(new Runnable() {
205 endSignal.countDown();
211 RpcResult<ServiceDeleteOutput> rpcResult = result.get();
213 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
218 public void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
219 ServicehandlerImpl servicehandlerImpl =
220 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
221 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
222 serviceDataStoreOperations);
223 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
224 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
225 result.addListener(new Runnable() {
228 endSignal.countDown();
234 RpcResult<ServiceFeasibilityCheckOutput> rpcResult = result.get();
236 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
240 public void serviceFeasibilityCheckShouldBeSuccessfulWhenPreformPCESuccessful()
241 throws ExecutionException, InterruptedException {
242 ServiceFeasibilityCheckInput input = ServiceDataUtils.buildServiceFeasibilityCheckInput();
243 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
244 ServicehandlerImpl servicehandlerImpl =
245 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
246 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
247 serviceDataStoreOperations);
248 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
249 servicehandlerImpl.serviceFeasibilityCheck(input);
250 result.addListener(new Runnable() {
253 endSignal.countDown();
259 RpcResult<ServiceFeasibilityCheckOutput> rpcResult = result.get();
261 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
265 public void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
266 ServicehandlerImpl servicehandlerImpl =
267 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
268 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
269 serviceDataStoreOperations);
270 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
271 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
272 result.addListener(new Runnable() {
275 endSignal.countDown();
281 RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
283 RpcStatus.Failed, rpcResult.getResult().getStatus());
288 public void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
289 ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
291 //action -> service reconfigure
292 ServicehandlerImpl servicehandlerImpl =
293 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
294 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
295 serviceDataStoreOperations);
296 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
298 result.addListener(new Runnable() {
301 endSignal.countDown();
307 RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
308 //ServiceReconfigureOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
310 RpcStatus.Failed, rpcResult.getResult().getStatus());
314 public void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
315 DataBroker dataBroker = getNewDataBroker();
318 // serviceReconfigure is calling service delete method in renderer
319 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
320 //create service to reconfigure
321 ServicehandlerImpl servicehandlerImpl =
322 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
323 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
324 serviceDataStoreOperations);
325 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
326 serviceDataStoreOperations.createService(createInput);
328 //service reconfigure test action
329 ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
330 //ServiceReconfigureInput is created with the same service information that is created before
331 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
332 result.addListener(new Runnable() {
335 endSignal.countDown();
341 RpcResult<ServiceReconfigureOutput> rpcResult = result.get();
343 RpcStatus.Successful, rpcResult.getResult().getStatus());
347 public void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
348 ServicehandlerImpl servicehandlerImpl =
349 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
350 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
351 serviceDataStoreOperations);
352 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
353 servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
354 result.addListener(new Runnable() {
357 endSignal.countDown();
363 RpcResult<ServiceRestorationOutput> rpcResult = result.get();
365 RpcStatus.Failed, rpcResult.getResult().getStatus());
370 public void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
371 ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
373 //action -> service restore
374 ServicehandlerImpl servicehandlerImpl =
375 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
376 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
377 serviceDataStoreOperations);
378 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
380 result.addListener(new Runnable() {
383 endSignal.countDown();
389 RpcResult<ServiceRestorationOutput> rpcResult = result.get();
390 //ServiceRestorationOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
392 RpcStatus.Failed, rpcResult.getResult().getStatus());
396 public void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
397 DataBroker dataBroker = getNewDataBroker();
400 // serviceRestoration is calling service delete method in renderer
401 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
402 //create service to restore
403 ServicehandlerImpl servicehandlerImpl =
404 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
405 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
406 serviceDataStoreOperations);
407 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
408 serviceDataStoreOperations.createService(createInput);
410 //service Restoration test action
411 ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
412 //ServiceRestorationInput is created with the same service information that is created before
413 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
414 result.addListener(new Runnable() {
417 endSignal.countDown();
423 RpcResult<ServiceRestorationOutput> rpcResult = result.get();
425 RpcStatus.Successful, rpcResult.getResult().getStatus());
429 public void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
430 ServicehandlerImpl servicehandlerImpl =
431 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
432 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
433 serviceDataStoreOperations);
434 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
435 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
436 result.addListener(new Runnable() {
439 endSignal.countDown();
445 RpcResult<ServiceRerouteOutput> rpcResult = result.get();
447 RpcStatus.Failed, rpcResult.getResult().getStatus());
451 public void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
452 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
454 //action -> service reconfigure
455 ServicehandlerImpl servicehandlerImpl =
456 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
457 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
458 serviceDataStoreOperations);
459 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
461 result.addListener(new Runnable() {
464 endSignal.countDown();
470 RpcResult<ServiceRerouteOutput> rpcResult = result.get();
471 //ServiceRerouteOutput doesn't have ConfigurationResponseCommon but have RpcStatus directly
473 RpcStatus.Failed, rpcResult.getResult().getStatus());
477 public void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
478 DataBroker dataBroker = getNewDataBroker();
481 // serviceReroute is calling service delete method in renderer
482 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
483 //create service to be rerouted later
484 ServicehandlerImpl servicehandlerImpl =
485 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
486 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
487 serviceDataStoreOperations);
488 ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
489 serviceDataStoreOperations.createService(createInput);
491 //service reroute test action
492 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
493 //ServiceRerouteInput is created with the same service information that is created before
494 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
495 result.addListener(new Runnable() {
498 endSignal.countDown();
504 RpcResult<ServiceRerouteOutput> rpcResult = result.get();
506 RpcStatus.Successful, rpcResult.getResult().getStatus());
510 public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
511 ServicehandlerImpl servicehandlerImpl =
512 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
513 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
514 serviceDataStoreOperations);
515 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
516 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder()
517 .setCommonId("").build());
518 result.addListener(new Runnable() {
521 endSignal.countDown();
527 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
529 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
531 LogMessages.SERVICE_NON_COMPLIANT,
532 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
536 public void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
537 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput();
538 ServicehandlerImpl servicehandlerImpl =
539 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
540 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
541 serviceDataStoreOperations);
542 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
543 result.addListener(new Runnable() {
546 endSignal.countDown();
552 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
554 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
558 public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
559 DataBroker dataBroker = getNewDataBroker();
560 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
562 //create temp service to delete in the temp delete action
563 ServicehandlerImpl servicehandlerImpl =
564 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
565 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
566 serviceDataStoreOperations);
567 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
568 serviceDataStoreOperations.createTempService(createInput);
571 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
572 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
573 result.addListener(new Runnable() {
576 endSignal.countDown();
582 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
584 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
588 public void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
589 ServicehandlerImpl servicehandlerImpl =
590 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
591 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
592 serviceDataStoreOperations);
593 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
594 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
595 result.addListener(new Runnable() {
598 endSignal.countDown();
604 RpcResult<TempServiceCreateOutput> rpcResult = result.get();
606 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
611 public void tempServiceCreateShouldBeSuccessfulWhenPreformPCESuccessful()
612 throws ExecutionException, InterruptedException {
613 TempServiceCreateInput input = ServiceDataUtils.buildTempServiceCreateInput();
614 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
616 ServicehandlerImpl servicehandlerImpl =
617 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
618 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
619 serviceDataStoreOperations);
621 ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(input);
622 result.addListener(new Runnable() {
625 endSignal.countDown();
631 RpcResult<TempServiceCreateOutput> rpcResult = result.get();
634 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());