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.times;
14 import static org.mockito.Mockito.verify;
15 import static org.mockito.Mockito.when;
16 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
18 import com.google.common.collect.ClassToInstanceMap;
19 import com.google.common.util.concurrent.Futures;
20 import com.google.common.util.concurrent.ListenableFuture;
21 import com.google.common.util.concurrent.ListeningExecutorService;
22 import com.google.common.util.concurrent.MoreExecutors;
24 import java.util.Optional;
25 import java.util.concurrent.CountDownLatch;
26 import java.util.concurrent.ExecutionException;
27 import java.util.concurrent.Executors;
28 import org.junit.Assert;
29 import org.junit.jupiter.api.BeforeEach;
30 import org.junit.jupiter.api.Test;
31 import org.junit.jupiter.api.extension.ExtendWith;
32 import org.mockito.Mock;
33 import org.mockito.junit.jupiter.MockitoExtension;
34 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
35 import org.opendaylight.mdsal.binding.api.RpcProviderService;
36 import org.opendaylight.transportpce.common.ResponseCodes;
37 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
38 import org.opendaylight.transportpce.pce.service.PathComputationService;
39 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
40 import org.opendaylight.transportpce.servicehandler.ServiceInput;
41 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
42 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
43 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
44 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
45 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
46 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
47 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
48 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
49 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
50 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
51 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
52 import org.opendaylight.transportpce.test.AbstractTest;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInputBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInputBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteOutput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfoBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
89 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
90 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
91 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
92 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
93 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
94 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
95 import org.opendaylight.yangtools.yang.common.RpcResult;
96 import org.opendaylight.yangtools.yang.common.Uint32;
98 @ExtendWith(MockitoExtension.class)
99 public class ServicehandlerImplTest extends AbstractTest {
101 private RpcProviderService rpcProviderService;
103 private PathComputationService pathComputationService;
105 private RendererServiceOperations rendererServiceOperations;
107 private NotificationPublishService notificationPublishService;
109 private PceListener pceListenerImpl;
111 private RendererListener rendererListenerImpl;
113 private NetworkListener networkModelListenerImpl;
116 private PathDescription pathDescription;
117 private ServiceDataStoreOperations serviceDataStoreOperations;
118 private CatalogDataStoreOperations catalogDataStoreOperations;
119 private ServiceCreateInput serviceCreateInput;
120 private ServiceDeleteInput serviceDeleteInput;
121 private ServiceReconfigureInput serviceReconfigureInput;
122 private ServiceRestorationInput serviceRestorationInput;
123 private ServiceRerouteInput serviceRerouteInput;
124 private ListeningExecutorService executorService;
125 private CountDownLatch endSignal;
126 private static final int NUM_THREADS = 5;
127 private PCEServiceWrapper pceServiceWrapper;
128 private RendererServiceWrapper rendererServiceWrapper;
132 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
133 endSignal = new CountDownLatch(1);
134 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
135 this.catalogDataStoreOperations =
136 new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
137 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
138 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
139 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
140 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
141 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
142 pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
143 pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
144 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
148 void testRpcRegistration() {
149 new ServicehandlerImpl(rpcProviderService, serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
150 networkModelListenerImpl, catalogDataStoreOperations, pathComputationService, rendererServiceOperations,
151 notificationPublishService);
152 verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
156 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
157 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
158 new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
159 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
160 .invoke(new ServiceCreateInputBuilder().build());
161 result.addListener(() -> endSignal.countDown(), executorService);
164 ResponseCodes.RESPONSE_FAILED,
165 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
169 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
170 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
171 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
172 .thenReturn(Optional.of(
173 new ServicesBuilder()
174 .setServiceName(serviceCreateInput.getServiceName())
176 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
177 new ServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
178 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
179 .invoke(serviceCreateInput);
180 result.addListener(() -> endSignal.countDown(), executorService);
183 ResponseCodes.RESPONSE_FAILED,
184 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
188 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
189 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
190 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
191 new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
192 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
193 .invoke(serviceCreateInput);
194 result.addListener(() -> endSignal.countDown(), executorService);
197 ResponseCodes.RESPONSE_OK,
198 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
202 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
203 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
204 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
205 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
206 .invoke(new ServiceDeleteInputBuilder()
207 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
211 result.addListener(() -> endSignal.countDown(), executorService);
214 ResponseCodes.RESPONSE_FAILED,
215 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
219 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
220 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
221 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
222 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
223 .invoke(serviceDeleteInput);
224 result.addListener(() -> endSignal.countDown(), executorService);
227 ResponseCodes.RESPONSE_FAILED,
228 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
232 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
233 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
234 serviceDataStoreOperations.createService(serviceCreateInput);
235 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
236 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
237 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
238 .invoke(serviceDeleteInput);
239 result.addListener(() -> endSignal.countDown(), executorService);
242 ResponseCodes.RESPONSE_OK,
243 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
247 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
248 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
249 new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
250 networkModelListenerImpl, pceServiceWrapper)
251 .invoke(new ServiceFeasibilityCheckInputBuilder().build());
252 result.addListener(() -> endSignal.countDown(), executorService);
255 ResponseCodes.RESPONSE_FAILED,
256 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
260 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
261 throws ExecutionException, InterruptedException {
262 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
263 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
264 new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
265 networkModelListenerImpl, pceServiceWrapper)
266 .invoke(ServiceDataUtils.buildServiceFeasibilityCheckInput());
267 result.addListener(() -> endSignal.countDown(), executorService);
270 ResponseCodes.RESPONSE_OK,
271 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
275 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
276 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
277 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
278 networkModelListenerImpl, rendererServiceWrapper)
279 .invoke(new ServiceReconfigureInputBuilder().setServiceName("").build());
280 result.addListener(() -> endSignal.countDown(), executorService);
286 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
287 //action -> service reconfigure
288 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
289 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
290 networkModelListenerImpl, rendererServiceWrapper)
291 .invoke(serviceReconfigureInput);
292 result.addListener(() -> endSignal.countDown(), executorService);
297 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
298 // serviceReconfigure is calling service delete method in renderer
299 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
300 //create service to reconfigure
301 serviceDataStoreOperations.createService(serviceCreateInput);
302 //service reconfigure test action
303 //ServiceReconfigureInput is created with the same service information that is created before
304 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
305 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
306 networkModelListenerImpl, rendererServiceWrapper)
307 .invoke(serviceReconfigureInput);
308 result.addListener(() -> endSignal.countDown(), executorService);
313 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
314 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
315 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
316 networkModelListenerImpl, rendererServiceWrapper)
317 .invoke(new ServiceRestorationInputBuilder()
320 result.addListener(() -> endSignal.countDown(), executorService);
325 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
326 //action -> service restore
327 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
328 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
329 networkModelListenerImpl, rendererServiceWrapper)
330 .invoke(serviceRestorationInput);
331 result.addListener(() -> endSignal.countDown(), executorService);
336 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
337 // serviceRestoration is calling service delete method in renderer
338 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
339 //create service to restore
340 serviceDataStoreOperations.createService(serviceCreateInput);
341 //service Restoration test action
342 //ServiceRestorationInput is created with the same service information that is created before
343 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
344 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
345 networkModelListenerImpl, rendererServiceWrapper)
346 .invoke(serviceRestorationInput);
347 result.addListener(() -> endSignal.countDown(), executorService);
352 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
353 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
354 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
355 .invoke(new ServiceRerouteInputBuilder()
358 result.addListener(() -> endSignal.countDown(), executorService);
361 ResponseCodes.RESPONSE_FAILED,
362 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
366 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
367 //action -> service reconfigure
368 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
369 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
370 .invoke(serviceRerouteInput);
371 result.addListener(() -> endSignal.countDown(), executorService);
374 ResponseCodes.RESPONSE_FAILED,
375 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
379 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
380 when(pathComputationService.pathComputationRerouteRequest(any()))
381 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
382 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
383 .setResponseCode(ResponseCodes.RESPONSE_OK)
386 Map<AToZKey, AToZ> atoz = Map.of(
390 .setResource(new ResourceBuilder()
391 .setResource(new TerminationPointBuilder()
392 .setTpNodeId("tpNodeIdC")
395 .setState(State.InService)
401 .setResource(new ResourceBuilder()
402 .setResource(new TerminationPointBuilder()
403 .setTpNodeId("tpNodeIdD")
406 .setState(State.InService)
408 .build(), new AToZKey("2"),
411 .setResource(new ResourceBuilder()
412 .setResource(new TerminationPointBuilder()
413 .setTpNodeId("tpNodeIdA")
416 .setState(State.InService)
421 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
422 new PathComputationRequestOutputBuilder()
423 .setResponseParameters(new ResponseParametersBuilder()
424 .setPathDescription(new PathDescriptionBuilder()
425 .setAToZDirection(new AToZDirectionBuilder()
427 .setRate(Uint32.valueOf(1))
429 .setZToADirection(new ZToADirectionBuilder()
430 .setRate(Uint32.valueOf(1))
435 serviceDataStoreOperations.createService(serviceCreateInput);
436 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
437 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
438 .invoke(serviceRerouteInput);
439 result.addListener(() -> endSignal.countDown(), executorService);
442 ResponseCodes.RESPONSE_OK,
443 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
447 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
448 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
449 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
450 rendererServiceWrapper)
451 .invoke(new TempServiceDeleteInputBuilder()
454 result.addListener(() -> endSignal.countDown(), executorService);
456 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
458 ResponseCodes.RESPONSE_FAILED,
459 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
461 LogMessages.SERVICE_NON_COMPLIANT,
462 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
466 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
467 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
468 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
469 rendererServiceWrapper)
470 .invoke(ServiceDataUtils.buildTempServiceDeleteInput());
471 result.addListener(() -> endSignal.countDown(), executorService);
474 ResponseCodes.RESPONSE_FAILED,
475 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
479 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
480 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
481 //create temp service to delete in the temp delete action
482 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
483 serviceDataStoreOperations.createTempService(createInput, pathDescription);
484 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
485 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
486 rendererServiceWrapper)
487 .invoke(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
488 result.addListener(() -> endSignal.countDown(), executorService);
491 ResponseCodes.RESPONSE_OK,
492 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
496 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
497 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
498 new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
499 networkModelListenerImpl, pceServiceWrapper)
500 .invoke(new TempServiceCreateInputBuilder().build());
501 result.addListener(() -> endSignal.countDown(), executorService);
504 ResponseCodes.RESPONSE_FAILED,
505 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
509 void tempServiceCreateShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
510 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
511 when(serviceDSOperations.getTempService(any()))
512 .thenReturn(Optional.of(
513 new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.list
515 .setCommonId("bad_commonId")
517 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
518 new TempServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
519 networkModelListenerImpl, pceServiceWrapper)
520 .invoke(ServiceDataUtils.buildTempServiceCreateInput());
521 result.addListener(() -> endSignal.countDown(), executorService);
524 ResponseCodes.RESPONSE_FAILED,
525 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
527 "Service 'Temp (commonId)' already exists in datastore",
528 result.get().getResult().getConfigurationResponseCommon().getResponseMessage());
532 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
533 throws ExecutionException, InterruptedException {
534 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
535 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
536 new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
537 networkModelListenerImpl, pceServiceWrapper)
538 .invoke(ServiceDataUtils.buildTempServiceCreateInput());
539 result.addListener(() -> endSignal.countDown(), executorService);
542 ResponseCodes.RESPONSE_OK,
543 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
547 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
548 throws ExecutionException, InterruptedException {
549 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
550 new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
551 .invoke(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
553 ResponseCodes.RESPONSE_FAILED,
554 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
558 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
559 throws ExecutionException, InterruptedException {
560 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
561 new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
562 .invoke(new AddSpecificOperationalModesToCatalogInputBuilder().build());
564 ResponseCodes.RESPONSE_FAILED,
565 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
569 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
570 throws ExecutionException, InterruptedException {
571 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
572 new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
573 .invoke(CatalogDataUtils.buildAddORToCatalogInput());
575 ResponseCodes.RESPONSE_OK,
576 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
580 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
581 throws ExecutionException, InterruptedException {
582 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
583 new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
584 .invoke(CatalogDataUtils.buildAddSpecificToCatalogInput());
586 ResponseCodes.RESPONSE_OK,
587 result.get().getResult().getConfigurationResponseCommon().getResponseCode());