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.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
80 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
81 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
82 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
83 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
84 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
85 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
89 import org.opendaylight.yangtools.yang.common.RpcResult;
90 import org.opendaylight.yangtools.yang.common.Uint32;
92 @ExtendWith(MockitoExtension.class)
93 public class ServicehandlerImplTest extends AbstractTest {
96 private PathComputationService pathComputationService;
98 private RendererServiceOperations rendererServiceOperations;
100 private NotificationPublishService notificationPublishService;
102 private PceListener pceListenerImpl;
104 private RendererListener rendererListenerImpl;
106 private NetworkListener networkModelListenerImpl;
109 private PathDescription pathDescription;
110 private ServiceDataStoreOperations serviceDataStoreOperations;
111 private CatalogDataStoreOperations catalogDataStoreOperations;
112 private ServiceCreateInput serviceCreateInput;
113 private ServiceDeleteInput serviceDeleteInput;
114 private ServiceReconfigureInput serviceReconfigureInput;
115 private ServiceRestorationInput serviceRestorationInput;
116 private ServiceRerouteInput serviceRerouteInput;
117 private ListeningExecutorService executorService;
118 private CountDownLatch endSignal;
119 private static final int NUM_THREADS = 5;
123 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
124 endSignal = new CountDownLatch(1);
125 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
126 this.catalogDataStoreOperations =
127 new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
128 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
129 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
130 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
131 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
132 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
133 pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
137 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
138 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
139 new ServicehandlerImpl(
140 pathComputationService, rendererServiceOperations, notificationPublishService,
141 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
142 serviceDataStoreOperations, catalogDataStoreOperations)
143 .serviceCreate(new ServiceCreateInputBuilder().build());
144 result.addListener(() -> endSignal.countDown(), executorService);
147 ResponseCodes.RESPONSE_FAILED,
148 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
152 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
153 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
154 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
155 .thenReturn(Optional.of(
156 new ServicesBuilder()
157 .setServiceName(serviceCreateInput.getServiceName())
159 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
160 new ServicehandlerImpl(
161 pathComputationService, rendererServiceOperations, notificationPublishService,
162 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
163 serviceDSOperations, catalogDataStoreOperations)
164 .serviceCreate(serviceCreateInput);
165 result.addListener(() -> endSignal.countDown(), executorService);
168 ResponseCodes.RESPONSE_FAILED,
169 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
173 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
174 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
175 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
176 new ServicehandlerImpl(
177 pathComputationService, rendererServiceOperations, notificationPublishService,
178 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
179 serviceDataStoreOperations, catalogDataStoreOperations)
180 .serviceCreate(serviceCreateInput);
181 result.addListener(() -> endSignal.countDown(), executorService);
184 ResponseCodes.RESPONSE_OK,
185 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
189 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
190 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
191 new ServicehandlerImpl(
192 pathComputationService, rendererServiceOperations, notificationPublishService,
193 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
194 serviceDataStoreOperations, catalogDataStoreOperations)
196 new ServiceDeleteInputBuilder()
197 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
201 result.addListener(() -> endSignal.countDown(), executorService);
204 ResponseCodes.RESPONSE_FAILED,
205 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
209 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
210 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
211 new ServicehandlerImpl(
212 pathComputationService, rendererServiceOperations, notificationPublishService,
213 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
214 serviceDataStoreOperations, catalogDataStoreOperations)
215 .serviceDelete(serviceDeleteInput);
216 result.addListener(() -> endSignal.countDown(), executorService);
219 ResponseCodes.RESPONSE_FAILED,
220 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
224 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
225 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
226 serviceDataStoreOperations.createService(serviceCreateInput);
227 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
228 new ServicehandlerImpl(
229 pathComputationService, rendererServiceOperations, notificationPublishService,
230 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
231 serviceDataStoreOperations, catalogDataStoreOperations)
232 .serviceDelete(serviceDeleteInput);
233 result.addListener(() -> endSignal.countDown(), executorService);
236 ResponseCodes.RESPONSE_OK,
237 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
241 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
242 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
243 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
244 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
245 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
246 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
247 result.addListener(() -> endSignal.countDown(), executorService);
250 ResponseCodes.RESPONSE_FAILED,
251 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
255 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
256 throws ExecutionException, InterruptedException {
257 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
258 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
259 new ServicehandlerImpl(
260 pathComputationService, rendererServiceOperations, notificationPublishService,
261 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
262 serviceDataStoreOperations, catalogDataStoreOperations)
263 .serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
264 result.addListener(() -> endSignal.countDown(), executorService);
267 ResponseCodes.RESPONSE_OK,
268 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
272 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
273 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
274 new ServicehandlerImpl(
275 pathComputationService, rendererServiceOperations, notificationPublishService,
276 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
277 serviceDataStoreOperations, catalogDataStoreOperations)
278 .serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
279 result.addListener(() -> endSignal.countDown(), executorService);
285 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
286 //action -> service reconfigure
287 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
288 new ServicehandlerImpl(
289 pathComputationService, rendererServiceOperations, notificationPublishService,
290 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
291 serviceDataStoreOperations, catalogDataStoreOperations)
292 .serviceReconfigure(serviceReconfigureInput);
293 result.addListener(() -> endSignal.countDown(), executorService);
298 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
299 // serviceReconfigure is calling service delete method in renderer
300 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
301 //create service to reconfigure
302 serviceDataStoreOperations.createService(serviceCreateInput);
303 //service reconfigure test action
304 //ServiceReconfigureInput is created with the same service information that is created before
305 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
306 new ServicehandlerImpl(
307 pathComputationService, rendererServiceOperations, notificationPublishService,
308 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
309 serviceDataStoreOperations, catalogDataStoreOperations)
310 .serviceReconfigure(serviceReconfigureInput);
311 result.addListener(() -> endSignal.countDown(), executorService);
316 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
317 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
318 new ServicehandlerImpl(
319 pathComputationService, rendererServiceOperations, notificationPublishService,
320 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
321 serviceDataStoreOperations, catalogDataStoreOperations)
322 .serviceRestoration(new ServiceRestorationInputBuilder()
325 result.addListener(() -> endSignal.countDown(), executorService);
330 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
331 //action -> service restore
332 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
333 new ServicehandlerImpl(
334 pathComputationService, rendererServiceOperations, notificationPublishService,
335 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
336 serviceDataStoreOperations, catalogDataStoreOperations)
337 .serviceRestoration(serviceRestorationInput);
338 result.addListener(() -> endSignal.countDown(), executorService);
343 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
344 // serviceRestoration is calling service delete method in renderer
345 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
346 //create service to restore
347 serviceDataStoreOperations.createService(serviceCreateInput);
348 //service Restoration test action
349 //ServiceRestorationInput is created with the same service information that is created before
350 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
351 new ServicehandlerImpl(
352 pathComputationService, rendererServiceOperations, notificationPublishService,
353 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
354 serviceDataStoreOperations, catalogDataStoreOperations)
355 .serviceRestoration(serviceRestorationInput);
356 result.addListener(() -> endSignal.countDown(), executorService);
361 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
362 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
363 new ServicehandlerImpl(
364 pathComputationService, rendererServiceOperations, notificationPublishService,
365 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
366 serviceDataStoreOperations, catalogDataStoreOperations)
367 .serviceReroute(new ServiceRerouteInputBuilder()
370 result.addListener(() -> endSignal.countDown(), executorService);
373 ResponseCodes.RESPONSE_FAILED,
374 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
378 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
379 //action -> service reconfigure
380 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
381 new ServicehandlerImpl(
382 pathComputationService, rendererServiceOperations, notificationPublishService,
383 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
384 serviceDataStoreOperations, catalogDataStoreOperations)
385 .serviceReroute(serviceRerouteInput);
386 result.addListener(() -> endSignal.countDown(), executorService);
389 ResponseCodes.RESPONSE_FAILED,
390 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
394 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
395 when(pathComputationService.pathComputationRerouteRequest(any()))
396 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
397 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
398 .setResponseCode(ResponseCodes.RESPONSE_OK)
401 Map<AToZKey, AToZ> atoz = Map.of(
405 .setResource(new ResourceBuilder()
406 .setResource(new TerminationPointBuilder()
407 .setTpNodeId("tpNodeIdC")
410 .setState(State.InService)
416 .setResource(new ResourceBuilder()
417 .setResource(new TerminationPointBuilder()
418 .setTpNodeId("tpNodeIdD")
421 .setState(State.InService)
423 .build(), new AToZKey("2"),
426 .setResource(new ResourceBuilder()
427 .setResource(new TerminationPointBuilder()
428 .setTpNodeId("tpNodeIdA")
431 .setState(State.InService)
436 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
437 new PathComputationRequestOutputBuilder()
438 .setResponseParameters(new ResponseParametersBuilder()
439 .setPathDescription(new PathDescriptionBuilder()
440 .setAToZDirection(new AToZDirectionBuilder()
442 .setRate(Uint32.valueOf(1))
444 .setZToADirection(new ZToADirectionBuilder()
445 .setRate(Uint32.valueOf(1))
450 serviceDataStoreOperations.createService(serviceCreateInput);
451 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
452 new ServicehandlerImpl(
453 pathComputationService, rendererServiceOperations, notificationPublishService,
454 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
455 serviceDataStoreOperations, catalogDataStoreOperations)
456 .serviceReroute(serviceRerouteInput);
457 result.addListener(() -> endSignal.countDown(), executorService);
460 ResponseCodes.RESPONSE_OK,
461 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
465 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
466 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
467 new ServicehandlerImpl(
468 pathComputationService, rendererServiceOperations, notificationPublishService,
469 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
470 serviceDataStoreOperations, catalogDataStoreOperations)
471 .tempServiceDelete(new TempServiceDeleteInputBuilder()
474 result.addListener(() -> endSignal.countDown(), executorService);
476 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
478 ResponseCodes.RESPONSE_FAILED,
479 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
481 LogMessages.SERVICE_NON_COMPLIANT,
482 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
486 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
487 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
488 new ServicehandlerImpl(
489 pathComputationService, rendererServiceOperations, notificationPublishService,
490 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
491 serviceDataStoreOperations, catalogDataStoreOperations)
492 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput());
493 result.addListener(() -> endSignal.countDown(), executorService);
496 ResponseCodes.RESPONSE_FAILED,
497 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
501 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
502 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
503 //create temp service to delete in the temp delete action
504 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
505 serviceDataStoreOperations.createTempService(createInput, pathDescription);
506 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
507 new ServicehandlerImpl(
508 pathComputationService, rendererServiceOperations, notificationPublishService,
509 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
510 serviceDataStoreOperations, catalogDataStoreOperations)
511 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
512 result.addListener(() -> endSignal.countDown(), executorService);
515 ResponseCodes.RESPONSE_OK,
516 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
520 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
521 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
522 new ServicehandlerImpl(
523 pathComputationService, rendererServiceOperations, notificationPublishService,
524 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
525 serviceDataStoreOperations, catalogDataStoreOperations)
526 .tempServiceCreate(new TempServiceCreateInputBuilder().build());
527 result.addListener(() -> endSignal.countDown(), executorService);
530 ResponseCodes.RESPONSE_FAILED,
531 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
535 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
536 throws ExecutionException, InterruptedException {
537 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
538 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
539 new ServicehandlerImpl(
540 pathComputationService, rendererServiceOperations, notificationPublishService,
541 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
542 serviceDataStoreOperations, catalogDataStoreOperations)
543 .tempServiceCreate(ServiceDataUtils.buildTempServiceCreateInput());
544 result.addListener(() -> endSignal.countDown(), executorService);
547 ResponseCodes.RESPONSE_OK,
548 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
552 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
553 throws ExecutionException, InterruptedException {
554 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
555 new ServicehandlerImpl(
556 pathComputationService, rendererServiceOperations, notificationPublishService,
557 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
558 serviceDataStoreOperations, catalogDataStoreOperations)
559 .addOpenroadmOperationalModesToCatalog(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
561 ResponseCodes.RESPONSE_FAILED,
562 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
566 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
567 throws ExecutionException, InterruptedException {
568 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
569 new ServicehandlerImpl(
570 pathComputationService, rendererServiceOperations, notificationPublishService,
571 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
572 serviceDataStoreOperations, catalogDataStoreOperations)
573 .addSpecificOperationalModesToCatalog(new AddSpecificOperationalModesToCatalogInputBuilder().build());
575 ResponseCodes.RESPONSE_FAILED,
576 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
580 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
581 throws ExecutionException, InterruptedException {
582 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
583 new ServicehandlerImpl(
584 pathComputationService, rendererServiceOperations, notificationPublishService,
585 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
586 serviceDataStoreOperations, catalogDataStoreOperations)
587 .addOpenroadmOperationalModesToCatalog(CatalogDataUtils.buildAddORToCatalogInput());
589 ResponseCodes.RESPONSE_OK,
590 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
594 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
595 throws ExecutionException, InterruptedException {
596 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
597 new ServicehandlerImpl(
598 pathComputationService, rendererServiceOperations, notificationPublishService,
599 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
600 serviceDataStoreOperations, catalogDataStoreOperations)
601 .addSpecificOperationalModesToCatalog(CatalogDataUtils.buildAddSpecificToCatalogInput());
603 ResponseCodes.RESPONSE_OK,
604 result.get().getResult().getConfigurationResponseCommon().getResponseCode());