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.Assert;
26 import org.junit.jupiter.api.BeforeEach;
27 import org.junit.jupiter.api.Test;
28 import org.junit.jupiter.api.extension.ExtendWith;
29 import org.mockito.Mock;
30 import org.mockito.junit.jupiter.MockitoExtension;
31 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
32 import org.opendaylight.transportpce.common.ResponseCodes;
33 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
34 import org.opendaylight.transportpce.pce.service.PathComputationService;
35 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
36 import org.opendaylight.transportpce.servicehandler.ServiceInput;
37 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
38 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
39 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
40 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
41 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
42 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
43 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
44 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
45 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
46 import org.opendaylight.transportpce.test.AbstractTest;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
79 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
80 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
81 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
82 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
84 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
88 import org.opendaylight.yangtools.yang.common.RpcResult;
89 import org.opendaylight.yangtools.yang.common.Uint32;
91 @ExtendWith(MockitoExtension.class)
92 public class ServicehandlerImplTest extends AbstractTest {
95 private PathComputationService pathComputationService;
97 private RendererServiceOperations rendererServiceOperations;
99 private NotificationPublishService notificationPublishService;
101 private PceListener pceListenerImpl;
103 private RendererListener rendererListenerImpl;
105 private NetworkListener networkModelListenerImpl;
107 private ServiceDataStoreOperations serviceDataStoreOperations;
108 private CatalogDataStoreOperations catalogDataStoreOperations;
109 private ServiceCreateInput serviceCreateInput;
110 private ServiceDeleteInput serviceDeleteInput;
111 private ServiceReconfigureInput serviceReconfigureInput;
112 private ServiceRestorationInput serviceRestorationInput;
113 private ServiceRerouteInput serviceRerouteInput;
114 private ListeningExecutorService executorService;
115 private CountDownLatch endSignal;
116 private static final int NUM_THREADS = 5;
120 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
121 endSignal = new CountDownLatch(1);
122 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
123 this.catalogDataStoreOperations =
124 new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
125 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
126 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
127 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
128 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
129 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
133 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
134 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
135 new ServicehandlerImpl(
136 pathComputationService, rendererServiceOperations, notificationPublishService,
137 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
138 serviceDataStoreOperations, catalogDataStoreOperations)
139 .serviceCreate(new ServiceCreateInputBuilder().build());
140 result.addListener(() -> endSignal.countDown(), executorService);
143 ResponseCodes.RESPONSE_FAILED,
144 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
148 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
149 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
150 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
151 .thenReturn(Optional.of(
152 new ServicesBuilder()
153 .setServiceName(serviceCreateInput.getServiceName())
155 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
156 new ServicehandlerImpl(
157 pathComputationService, rendererServiceOperations, notificationPublishService,
158 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
159 serviceDSOperations, catalogDataStoreOperations)
160 .serviceCreate(serviceCreateInput);
161 result.addListener(() -> endSignal.countDown(), executorService);
164 ResponseCodes.RESPONSE_FAILED,
165 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
169 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
170 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
171 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
172 new ServicehandlerImpl(
173 pathComputationService, rendererServiceOperations, notificationPublishService,
174 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
175 serviceDataStoreOperations, catalogDataStoreOperations)
176 .serviceCreate(serviceCreateInput);
177 result.addListener(() -> endSignal.countDown(), executorService);
180 ResponseCodes.RESPONSE_OK,
181 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
185 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
186 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
187 new ServicehandlerImpl(
188 pathComputationService, rendererServiceOperations, notificationPublishService,
189 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
190 serviceDataStoreOperations, catalogDataStoreOperations)
192 new ServiceDeleteInputBuilder()
193 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
197 result.addListener(() -> endSignal.countDown(), executorService);
200 ResponseCodes.RESPONSE_FAILED,
201 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
205 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
206 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
207 new ServicehandlerImpl(
208 pathComputationService, rendererServiceOperations, notificationPublishService,
209 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
210 serviceDataStoreOperations, catalogDataStoreOperations)
211 .serviceDelete(serviceDeleteInput);
212 result.addListener(() -> endSignal.countDown(), executorService);
215 ResponseCodes.RESPONSE_FAILED,
216 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
220 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
221 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
222 serviceDataStoreOperations.createService(serviceCreateInput);
223 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
224 new ServicehandlerImpl(
225 pathComputationService, rendererServiceOperations, notificationPublishService,
226 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
227 serviceDataStoreOperations, catalogDataStoreOperations)
228 .serviceDelete(serviceDeleteInput);
229 result.addListener(() -> endSignal.countDown(), executorService);
232 ResponseCodes.RESPONSE_OK,
233 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
237 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
238 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
239 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
240 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
241 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
242 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
243 result.addListener(() -> endSignal.countDown(), executorService);
246 ResponseCodes.RESPONSE_FAILED,
247 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
251 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
252 throws ExecutionException, InterruptedException {
253 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
254 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
255 new ServicehandlerImpl(
256 pathComputationService, rendererServiceOperations, notificationPublishService,
257 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
258 serviceDataStoreOperations, catalogDataStoreOperations)
259 .serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
260 result.addListener(() -> endSignal.countDown(), executorService);
263 ResponseCodes.RESPONSE_OK,
264 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
268 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
269 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
270 new ServicehandlerImpl(
271 pathComputationService, rendererServiceOperations, notificationPublishService,
272 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
273 serviceDataStoreOperations, catalogDataStoreOperations)
274 .serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
275 result.addListener(() -> endSignal.countDown(), executorService);
281 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
282 //action -> service reconfigure
283 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
284 new ServicehandlerImpl(
285 pathComputationService, rendererServiceOperations, notificationPublishService,
286 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
287 serviceDataStoreOperations, catalogDataStoreOperations)
288 .serviceReconfigure(serviceReconfigureInput);
289 result.addListener(() -> endSignal.countDown(), executorService);
294 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
295 // serviceReconfigure is calling service delete method in renderer
296 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
297 //create service to reconfigure
298 serviceDataStoreOperations.createService(serviceCreateInput);
299 //service reconfigure test action
300 //ServiceReconfigureInput is created with the same service information that is created before
301 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
302 new ServicehandlerImpl(
303 pathComputationService, rendererServiceOperations, notificationPublishService,
304 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
305 serviceDataStoreOperations, catalogDataStoreOperations)
306 .serviceReconfigure(serviceReconfigureInput);
307 result.addListener(() -> endSignal.countDown(), executorService);
312 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
313 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
314 new ServicehandlerImpl(
315 pathComputationService, rendererServiceOperations, notificationPublishService,
316 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
317 serviceDataStoreOperations, catalogDataStoreOperations)
318 .serviceRestoration(new ServiceRestorationInputBuilder()
321 result.addListener(() -> endSignal.countDown(), executorService);
326 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
327 //action -> service restore
328 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
329 new ServicehandlerImpl(
330 pathComputationService, rendererServiceOperations, notificationPublishService,
331 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
332 serviceDataStoreOperations, catalogDataStoreOperations)
333 .serviceRestoration(serviceRestorationInput);
334 result.addListener(() -> endSignal.countDown(), executorService);
339 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
340 // serviceRestoration is calling service delete method in renderer
341 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
342 //create service to restore
343 serviceDataStoreOperations.createService(serviceCreateInput);
344 //service Restoration test action
345 //ServiceRestorationInput is created with the same service information that is created before
346 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
347 new ServicehandlerImpl(
348 pathComputationService, rendererServiceOperations, notificationPublishService,
349 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
350 serviceDataStoreOperations, catalogDataStoreOperations)
351 .serviceRestoration(serviceRestorationInput);
352 result.addListener(() -> endSignal.countDown(), executorService);
357 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
358 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
359 new ServicehandlerImpl(
360 pathComputationService, rendererServiceOperations, notificationPublishService,
361 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
362 serviceDataStoreOperations, catalogDataStoreOperations)
363 .serviceReroute(new ServiceRerouteInputBuilder()
366 result.addListener(() -> endSignal.countDown(), executorService);
369 ResponseCodes.RESPONSE_FAILED,
370 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
374 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
375 //action -> service reconfigure
376 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
377 new ServicehandlerImpl(
378 pathComputationService, rendererServiceOperations, notificationPublishService,
379 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
380 serviceDataStoreOperations, catalogDataStoreOperations)
381 .serviceReroute(serviceRerouteInput);
382 result.addListener(() -> endSignal.countDown(), executorService);
385 ResponseCodes.RESPONSE_FAILED,
386 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
390 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
391 when(pathComputationService.pathComputationRerouteRequest(any()))
392 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
393 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
394 .setResponseCode(ResponseCodes.RESPONSE_OK)
397 Map<AToZKey, AToZ> atoz = Map.of(
401 .setResource(new ResourceBuilder()
402 .setResource(new TerminationPointBuilder()
403 .setTpNodeId("tpNodeIdC")
406 .setState(State.InService)
412 .setResource(new ResourceBuilder()
413 .setResource(new TerminationPointBuilder()
414 .setTpNodeId("tpNodeIdD")
417 .setState(State.InService)
419 .build(), new AToZKey("2"),
422 .setResource(new ResourceBuilder()
423 .setResource(new TerminationPointBuilder()
424 .setTpNodeId("tpNodeIdA")
427 .setState(State.InService)
432 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
433 new PathComputationRequestOutputBuilder()
434 .setResponseParameters(new ResponseParametersBuilder()
435 .setPathDescription(new PathDescriptionBuilder()
436 .setAToZDirection(new AToZDirectionBuilder()
438 .setRate(Uint32.valueOf(1))
440 .setZToADirection(new ZToADirectionBuilder()
441 .setRate(Uint32.valueOf(1))
446 serviceDataStoreOperations.createService(serviceCreateInput);
447 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
448 new ServicehandlerImpl(
449 pathComputationService, rendererServiceOperations, notificationPublishService,
450 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
451 serviceDataStoreOperations, catalogDataStoreOperations)
452 .serviceReroute(serviceRerouteInput);
453 result.addListener(() -> endSignal.countDown(), executorService);
456 ResponseCodes.RESPONSE_OK,
457 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
461 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
462 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
463 new ServicehandlerImpl(
464 pathComputationService, rendererServiceOperations, notificationPublishService,
465 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
466 serviceDataStoreOperations, catalogDataStoreOperations)
467 .tempServiceDelete(new TempServiceDeleteInputBuilder()
470 result.addListener(() -> endSignal.countDown(), executorService);
472 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
474 ResponseCodes.RESPONSE_FAILED,
475 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
477 LogMessages.SERVICE_NON_COMPLIANT,
478 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
482 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
483 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
484 new ServicehandlerImpl(
485 pathComputationService, rendererServiceOperations, notificationPublishService,
486 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
487 serviceDataStoreOperations, catalogDataStoreOperations)
488 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput());
489 result.addListener(() -> endSignal.countDown(), executorService);
492 ResponseCodes.RESPONSE_FAILED,
493 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
497 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
498 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
499 //create temp service to delete in the temp delete action
500 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
501 serviceDataStoreOperations.createTempService(createInput);
502 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
503 new ServicehandlerImpl(
504 pathComputationService, rendererServiceOperations, notificationPublishService,
505 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
506 serviceDataStoreOperations, catalogDataStoreOperations)
507 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
508 result.addListener(() -> endSignal.countDown(), executorService);
511 ResponseCodes.RESPONSE_OK,
512 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
516 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
517 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
518 new ServicehandlerImpl(
519 pathComputationService, rendererServiceOperations, notificationPublishService,
520 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
521 serviceDataStoreOperations, catalogDataStoreOperations)
522 .tempServiceCreate(new TempServiceCreateInputBuilder().build());
523 result.addListener(() -> endSignal.countDown(), executorService);
526 ResponseCodes.RESPONSE_FAILED,
527 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
531 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
532 throws ExecutionException, InterruptedException {
533 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
534 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
535 new ServicehandlerImpl(
536 pathComputationService, rendererServiceOperations, notificationPublishService,
537 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
538 serviceDataStoreOperations, catalogDataStoreOperations)
539 .tempServiceCreate(ServiceDataUtils.buildTempServiceCreateInput());
540 result.addListener(() -> endSignal.countDown(), executorService);
543 ResponseCodes.RESPONSE_OK,
544 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
548 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
549 throws ExecutionException, InterruptedException {
550 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
551 new ServicehandlerImpl(
552 pathComputationService, rendererServiceOperations, notificationPublishService,
553 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
554 serviceDataStoreOperations, catalogDataStoreOperations)
555 .addOpenroadmOperationalModesToCatalog(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
557 ResponseCodes.RESPONSE_FAILED,
558 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
562 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
563 throws ExecutionException, InterruptedException {
564 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
565 new ServicehandlerImpl(
566 pathComputationService, rendererServiceOperations, notificationPublishService,
567 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
568 serviceDataStoreOperations, catalogDataStoreOperations)
569 .addSpecificOperationalModesToCatalog(new AddSpecificOperationalModesToCatalogInputBuilder().build());
571 ResponseCodes.RESPONSE_FAILED,
572 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
576 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
577 throws ExecutionException, InterruptedException {
578 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
579 new ServicehandlerImpl(
580 pathComputationService, rendererServiceOperations, notificationPublishService,
581 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
582 serviceDataStoreOperations, catalogDataStoreOperations)
583 .addOpenroadmOperationalModesToCatalog(CatalogDataUtils.buildAddORToCatalogInput());
585 ResponseCodes.RESPONSE_OK,
586 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
590 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
591 throws ExecutionException, InterruptedException {
592 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
593 new ServicehandlerImpl(
594 pathComputationService, rendererServiceOperations, notificationPublishService,
595 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
596 serviceDataStoreOperations, catalogDataStoreOperations)
597 .addSpecificOperationalModesToCatalog(CatalogDataUtils.buildAddSpecificToCatalogInput());
599 ResponseCodes.RESPONSE_OK,
600 result.get().getResult().getConfigurationResponseCommon().getResponseCode());