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.junit.jupiter.api.Assertions.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.Mockito.mock;
13 import static org.mockito.Mockito.when;
14 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
16 import com.google.common.util.concurrent.Futures;
17 import com.google.common.util.concurrent.ListenableFuture;
18 import com.google.common.util.concurrent.ListeningExecutorService;
19 import com.google.common.util.concurrent.MoreExecutors;
21 import java.util.Optional;
22 import java.util.concurrent.CountDownLatch;
23 import java.util.concurrent.ExecutionException;
24 import java.util.concurrent.Executors;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Test;
27 import org.junit.jupiter.api.extension.ExtendWith;
28 import org.mockito.Mock;
29 import org.mockito.junit.jupiter.MockitoExtension;
30 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
31 import org.opendaylight.transportpce.common.ResponseCodes;
32 import org.opendaylight.transportpce.pce.service.PathComputationService;
33 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
34 import org.opendaylight.transportpce.servicehandler.ServiceInput;
35 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
36 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
37 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
38 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
39 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
40 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
41 import org.opendaylight.transportpce.test.AbstractTest;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
74 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
76 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.ResourceBuilder;
77 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPointBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
79 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
80 import org.opendaylight.yangtools.yang.common.RpcResult;
81 import org.opendaylight.yangtools.yang.common.Uint32;
83 @ExtendWith(MockitoExtension.class)
84 public class ServicehandlerImplTest extends AbstractTest {
87 private PathComputationService pathComputationService;
89 private RendererServiceOperations rendererServiceOperations;
91 private NotificationPublishService notificationPublishService;
93 private PceListenerImpl pceListenerImpl;
95 private RendererListenerImpl rendererListenerImpl;
97 private NetworkModelListenerImpl networkModelListenerImpl;
99 private ServiceDataStoreOperations serviceDataStoreOperations;
100 private ServiceCreateInput serviceCreateInput;
101 private ServiceDeleteInput serviceDeleteInput;
102 private ServiceReconfigureInput serviceReconfigureInput;
103 private ServiceRestorationInput serviceRestorationInput;
104 private ServiceRerouteInput serviceRerouteInput;
105 private ListeningExecutorService executorService;
106 private CountDownLatch endSignal;
107 private static final int NUM_THREADS = 5;
111 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
112 endSignal = new CountDownLatch(1);
113 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
114 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
115 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
116 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
117 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
118 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
122 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
123 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
124 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
125 networkModelListenerImpl, serviceDataStoreOperations);
126 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl
127 .serviceCreate(new ServiceCreateInputBuilder().build());
128 result.addListener(() -> endSignal.countDown(), executorService);
131 ResponseCodes.RESPONSE_FAILED,
132 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
136 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException,
137 InterruptedException {
138 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
139 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
140 .thenReturn(Optional.of(
141 new ServicesBuilder()
142 .setServiceName(serviceCreateInput.getServiceName())
144 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
145 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
146 networkModelListenerImpl, serviceDSOperations);
147 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
148 result.addListener(() -> endSignal.countDown(), executorService);
152 ResponseCodes.RESPONSE_FAILED,
153 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
157 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful()
158 throws ExecutionException, InterruptedException {
159 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
160 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
161 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
162 networkModelListenerImpl, serviceDataStoreOperations);
163 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
164 result.addListener(() -> endSignal.countDown(), executorService);
168 ResponseCodes.RESPONSE_OK,
169 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
173 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
174 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
175 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
176 networkModelListenerImpl, serviceDataStoreOperations);
177 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(
178 new ServiceDeleteInputBuilder()
179 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
183 result.addListener(() -> endSignal.countDown(), executorService);
187 ResponseCodes.RESPONSE_FAILED,
188 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
192 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
193 ServicehandlerImpl servicehandlerImpl =
194 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
195 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
196 serviceDataStoreOperations);
197 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
198 result.addListener(() -> endSignal.countDown(), executorService);
202 ResponseCodes.RESPONSE_FAILED,
203 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
207 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
208 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
209 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
210 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
211 networkModelListenerImpl, serviceDataStoreOperations);
212 serviceDataStoreOperations.createService(serviceCreateInput);
213 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
214 result.addListener(() -> endSignal.countDown(), executorService);
218 ResponseCodes.RESPONSE_OK,
219 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
224 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
225 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
226 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
227 networkModelListenerImpl, serviceDataStoreOperations);
228 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
229 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
230 result.addListener(() -> endSignal.countDown(), executorService);
234 ResponseCodes.RESPONSE_FAILED,
235 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
239 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
240 throws ExecutionException, InterruptedException {
241 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
242 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
243 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
244 networkModelListenerImpl, serviceDataStoreOperations);
245 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
246 servicehandlerImpl.serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
247 result.addListener(() -> endSignal.countDown(), executorService);
251 ResponseCodes.RESPONSE_OK,
252 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
256 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
257 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
258 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
259 networkModelListenerImpl, serviceDataStoreOperations);
260 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
261 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
262 result.addListener(() -> endSignal.countDown(), executorService);
269 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
270 //action -> service reconfigure
271 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
272 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
273 networkModelListenerImpl, serviceDataStoreOperations);
274 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
275 serviceReconfigureInput);
277 result.addListener(() -> endSignal.countDown(), executorService);
283 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
284 // serviceReconfigure is calling service delete method in renderer
285 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
286 //create service to reconfigure
287 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
288 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
289 networkModelListenerImpl, serviceDataStoreOperations);
290 serviceDataStoreOperations.createService(serviceCreateInput);
292 //service reconfigure test action
293 //ServiceReconfigureInput is created with the same service information that is created before
294 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
295 serviceReconfigureInput);
296 result.addListener(() -> endSignal.countDown(), executorService);
302 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
303 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
304 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
305 networkModelListenerImpl, serviceDataStoreOperations);
306 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl
307 .serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
308 result.addListener(() -> endSignal.countDown(), executorService);
315 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
316 //action -> service restore
317 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
318 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
319 networkModelListenerImpl, serviceDataStoreOperations);
320 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
321 serviceRestorationInput);
323 result.addListener(() -> endSignal.countDown(), executorService);
329 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
330 // serviceRestoration is calling service delete method in renderer
331 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
332 //create service to restore
333 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
334 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
335 networkModelListenerImpl, serviceDataStoreOperations);
336 serviceDataStoreOperations.createService(serviceCreateInput);
338 //service Restoration test action
339 //ServiceRestorationInput is created with the same service information that is created before
340 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
341 serviceRestorationInput);
342 result.addListener(() -> endSignal.countDown(), executorService);
348 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
349 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
350 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
351 networkModelListenerImpl, serviceDataStoreOperations);
352 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
353 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
354 result.addListener(() -> endSignal.countDown(), executorService);
359 ResponseCodes.RESPONSE_FAILED,
360 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
364 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
365 //action -> service reconfigure
366 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
367 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
368 networkModelListenerImpl, serviceDataStoreOperations);
369 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl
370 .serviceReroute(serviceRerouteInput);
372 result.addListener(() -> endSignal.countDown(), executorService);
377 ResponseCodes.RESPONSE_FAILED,
378 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
382 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
383 when(pathComputationService.pathComputationRerouteRequest(any()))
384 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
385 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
386 .setResponseCode(ResponseCodes.RESPONSE_OK)
389 Map<AToZKey, AToZ> atoz = Map.of(
393 .setResource(new ResourceBuilder()
394 .setResource(new TerminationPointBuilder()
395 .setTpNodeId("tpNodeIdC")
398 .setState(State.InService)
404 .setResource(new ResourceBuilder()
405 .setResource(new TerminationPointBuilder()
406 .setTpNodeId("tpNodeIdD")
409 .setState(State.InService)
411 .build(), new AToZKey("2"),
414 .setResource(new ResourceBuilder()
415 .setResource(new TerminationPointBuilder()
416 .setTpNodeId("tpNodeIdA")
419 .setState(State.InService)
424 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
425 new PathComputationRequestOutputBuilder()
426 .setResponseParameters(new ResponseParametersBuilder()
427 .setPathDescription(new PathDescriptionBuilder()
428 .setAToZDirection(new AToZDirectionBuilder()
430 .setRate(Uint32.valueOf(1))
432 .setZToADirection(new ZToADirectionBuilder()
433 .setRate(Uint32.valueOf(1))
439 serviceDataStoreOperations.createService(serviceCreateInput);
440 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = new ServicehandlerImpl(getNewDataBroker(),
441 pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl,
442 rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations)
443 .serviceReroute(serviceRerouteInput);
444 result.addListener(() -> endSignal.countDown(), executorService);
449 ResponseCodes.RESPONSE_OK,
450 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
454 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
455 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
456 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
457 networkModelListenerImpl, serviceDataStoreOperations);
458 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
459 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder().setCommonId("").build());
460 result.addListener(() -> endSignal.countDown(), executorService);
464 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
466 ResponseCodes.RESPONSE_FAILED,
467 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
469 LogMessages.SERVICE_NON_COMPLIANT,
470 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
474 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
475 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
476 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
477 networkModelListenerImpl, serviceDataStoreOperations);
478 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(
479 ServiceDataUtils.buildTempServiceDeleteInput());
480 result.addListener(() -> endSignal.countDown(), executorService);
484 ResponseCodes.RESPONSE_FAILED,
485 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
489 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
490 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
492 //create temp service to delete in the temp delete action
493 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
494 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
495 networkModelListenerImpl, serviceDataStoreOperations);
496 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
497 serviceDataStoreOperations.createTempService(createInput);
499 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
500 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
501 result.addListener(() -> endSignal.countDown(), executorService);
505 ResponseCodes.RESPONSE_OK,
506 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
510 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
511 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
512 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
513 networkModelListenerImpl, serviceDataStoreOperations);
514 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
515 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
516 result.addListener(() -> endSignal.countDown(), executorService);
520 ResponseCodes.RESPONSE_FAILED,
521 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
525 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
526 throws ExecutionException, InterruptedException {
527 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
529 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
530 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
531 networkModelListenerImpl, serviceDataStoreOperations);
533 ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(
534 ServiceDataUtils.buildTempServiceCreateInput());
535 result.addListener(() -> endSignal.countDown(), executorService);
539 ResponseCodes.RESPONSE_OK,
540 result.get().getResult().getConfigurationResponseCommon().getResponseCode());