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.util.concurrent.Futures;
19 import com.google.common.util.concurrent.ListenableFuture;
20 import com.google.common.util.concurrent.ListeningExecutorService;
21 import com.google.common.util.concurrent.MoreExecutors;
23 import java.util.Optional;
24 import java.util.concurrent.CountDownLatch;
25 import java.util.concurrent.ExecutionException;
26 import java.util.concurrent.Executors;
27 import org.junit.Assert;
28 import org.junit.jupiter.api.BeforeEach;
29 import org.junit.jupiter.api.Test;
30 import org.junit.jupiter.api.extension.ExtendWith;
31 import org.mockito.Mock;
32 import org.mockito.junit.jupiter.MockitoExtension;
33 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
34 import org.opendaylight.mdsal.binding.api.RpcProviderService;
35 import org.opendaylight.transportpce.common.ResponseCodes;
36 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
37 import org.opendaylight.transportpce.pce.service.PathComputationService;
38 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
39 import org.opendaylight.transportpce.servicehandler.ServiceInput;
40 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
41 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
42 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
43 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
44 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
45 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
46 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
47 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
48 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
49 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
50 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
51 import org.opendaylight.transportpce.test.AbstractTest;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogInputBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogOutput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInputBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckOutput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInputBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureOutput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteOutput;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfoBuilder;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
89 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
90 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
91 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
92 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
93 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
94 import org.opendaylight.yangtools.yang.common.RpcResult;
95 import org.opendaylight.yangtools.yang.common.Uint32;
97 @ExtendWith(MockitoExtension.class)
98 public class ServicehandlerImplTest extends AbstractTest {
100 private RpcProviderService rpcProviderService;
102 private PathComputationService pathComputationService;
104 private RendererServiceOperations rendererServiceOperations;
106 private NotificationPublishService notificationPublishService;
108 private PceListener pceListenerImpl;
110 private RendererListener rendererListenerImpl;
112 private NetworkListener networkModelListenerImpl;
115 private PathDescription pathDescription;
116 private ServiceDataStoreOperations serviceDataStoreOperations;
117 private CatalogDataStoreOperations catalogDataStoreOperations;
118 private ServiceCreateInput serviceCreateInput;
119 private ServiceDeleteInput serviceDeleteInput;
120 private ServiceReconfigureInput serviceReconfigureInput;
121 private ServiceRestorationInput serviceRestorationInput;
122 private ServiceRerouteInput serviceRerouteInput;
123 private ListeningExecutorService executorService;
124 private CountDownLatch endSignal;
125 private static final int NUM_THREADS = 5;
126 private PCEServiceWrapper pceServiceWrapper;
127 private RendererServiceWrapper rendererServiceWrapper;
131 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
132 endSignal = new CountDownLatch(1);
133 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
134 this.catalogDataStoreOperations =
135 new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
136 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
137 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
138 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
139 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
140 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
141 pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
142 pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
143 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
147 void testRpcRegistration() {
148 new ServicehandlerImpl(rpcProviderService, serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
149 networkModelListenerImpl, catalogDataStoreOperations, pathComputationService, rendererServiceOperations,
150 notificationPublishService);
151 verify(rpcProviderService, times(1)).registerRpcImplementations(any());
155 // void testNotImplementedRpc() throws InterruptedException, ExecutionException {
156 // ListenableFuture<RpcResult<ServiceSrlgGetOutput>> result = new ServicehandlerImpl(rpcProviderService,
157 // serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
158 // catalogDataStoreOperations, pathComputationService, rendererServiceOperations,
159 // notificationPublishService)
160 // .serviceSrlgGet(new ServiceSrlgGetInputBuilder().build());
162 // result.addListener(() -> endSignal.countDown(), executorService);
163 // endSignal.await();
164 // assertNotNull(result.get());
165 // assertFalse(result.get().isSuccessful());
166 // assertNull(result.get().getResult());
167 // assertEquals(ErrorType.RPC, result.get().getErrors().get(0).getErrorType());
168 // assertEquals(ErrorSeverity.ERROR, result.get().getErrors().get(0).getSeverity());
169 // assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, result.get().getErrors().get(0).getTag());
170 // assertEquals("RPC not implemented yet", result.get().getErrors().get(0).getMessage());
174 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
175 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
176 new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
177 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
178 .invoke(new ServiceCreateInputBuilder().build());
179 result.addListener(() -> endSignal.countDown(), executorService);
182 ResponseCodes.RESPONSE_FAILED,
183 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
187 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
188 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
189 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
190 .thenReturn(Optional.of(
191 new ServicesBuilder()
192 .setServiceName(serviceCreateInput.getServiceName())
194 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
195 new ServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
196 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
197 .invoke(serviceCreateInput);
198 result.addListener(() -> endSignal.countDown(), executorService);
201 ResponseCodes.RESPONSE_FAILED,
202 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
206 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
207 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
208 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
209 new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
210 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
211 .invoke(serviceCreateInput);
212 result.addListener(() -> endSignal.countDown(), executorService);
215 ResponseCodes.RESPONSE_OK,
216 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
220 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
221 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
222 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
223 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
224 .invoke(new ServiceDeleteInputBuilder()
225 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
229 result.addListener(() -> endSignal.countDown(), executorService);
232 ResponseCodes.RESPONSE_FAILED,
233 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
237 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
238 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
239 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
240 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
241 .invoke(serviceDeleteInput);
242 result.addListener(() -> endSignal.countDown(), executorService);
245 ResponseCodes.RESPONSE_FAILED,
246 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
250 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
251 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
252 serviceDataStoreOperations.createService(serviceCreateInput);
253 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
254 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
255 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
256 .invoke(serviceDeleteInput);
257 result.addListener(() -> endSignal.countDown(), executorService);
260 ResponseCodes.RESPONSE_OK,
261 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
265 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
266 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
267 new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
268 networkModelListenerImpl, pceServiceWrapper)
269 .invoke(new ServiceFeasibilityCheckInputBuilder().build());
270 result.addListener(() -> endSignal.countDown(), executorService);
273 ResponseCodes.RESPONSE_FAILED,
274 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
278 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
279 throws ExecutionException, InterruptedException {
280 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
281 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
282 new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
283 networkModelListenerImpl, pceServiceWrapper)
284 .invoke(ServiceDataUtils.buildServiceFeasibilityCheckInput());
285 result.addListener(() -> endSignal.countDown(), executorService);
288 ResponseCodes.RESPONSE_OK,
289 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
293 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
294 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
295 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
296 networkModelListenerImpl, rendererServiceWrapper)
297 .invoke(new ServiceReconfigureInputBuilder().setServiceName("").build());
298 result.addListener(() -> endSignal.countDown(), executorService);
304 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
305 //action -> service reconfigure
306 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
307 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
308 networkModelListenerImpl, rendererServiceWrapper)
309 .invoke(serviceReconfigureInput);
310 result.addListener(() -> endSignal.countDown(), executorService);
315 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
316 // serviceReconfigure is calling service delete method in renderer
317 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
318 //create service to reconfigure
319 serviceDataStoreOperations.createService(serviceCreateInput);
320 //service reconfigure test action
321 //ServiceReconfigureInput is created with the same service information that is created before
322 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
323 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
324 networkModelListenerImpl, rendererServiceWrapper)
325 .invoke(serviceReconfigureInput);
326 result.addListener(() -> endSignal.countDown(), executorService);
331 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
332 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
333 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
334 networkModelListenerImpl, rendererServiceWrapper)
335 .invoke(new ServiceRestorationInputBuilder()
338 result.addListener(() -> endSignal.countDown(), executorService);
343 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
344 //action -> service restore
345 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
346 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
347 networkModelListenerImpl, rendererServiceWrapper)
348 .invoke(serviceRestorationInput);
349 result.addListener(() -> endSignal.countDown(), executorService);
354 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
355 // serviceRestoration is calling service delete method in renderer
356 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
357 //create service to restore
358 serviceDataStoreOperations.createService(serviceCreateInput);
359 //service Restoration test action
360 //ServiceRestorationInput is created with the same service information that is created before
361 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
362 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
363 networkModelListenerImpl, rendererServiceWrapper)
364 .invoke(serviceRestorationInput);
365 result.addListener(() -> endSignal.countDown(), executorService);
370 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
371 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
372 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
373 .invoke(new ServiceRerouteInputBuilder()
376 result.addListener(() -> endSignal.countDown(), executorService);
379 ResponseCodes.RESPONSE_FAILED,
380 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
384 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
385 //action -> service reconfigure
386 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
387 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
388 .invoke(serviceRerouteInput);
389 result.addListener(() -> endSignal.countDown(), executorService);
392 ResponseCodes.RESPONSE_FAILED,
393 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
397 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
398 when(pathComputationService.pathComputationRerouteRequest(any()))
399 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
400 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
401 .setResponseCode(ResponseCodes.RESPONSE_OK)
404 Map<AToZKey, AToZ> atoz = Map.of(
408 .setResource(new ResourceBuilder()
409 .setResource(new TerminationPointBuilder()
410 .setTpNodeId("tpNodeIdC")
413 .setState(State.InService)
419 .setResource(new ResourceBuilder()
420 .setResource(new TerminationPointBuilder()
421 .setTpNodeId("tpNodeIdD")
424 .setState(State.InService)
426 .build(), new AToZKey("2"),
429 .setResource(new ResourceBuilder()
430 .setResource(new TerminationPointBuilder()
431 .setTpNodeId("tpNodeIdA")
434 .setState(State.InService)
439 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
440 new PathComputationRequestOutputBuilder()
441 .setResponseParameters(new ResponseParametersBuilder()
442 .setPathDescription(new PathDescriptionBuilder()
443 .setAToZDirection(new AToZDirectionBuilder()
445 .setRate(Uint32.valueOf(1))
447 .setZToADirection(new ZToADirectionBuilder()
448 .setRate(Uint32.valueOf(1))
453 serviceDataStoreOperations.createService(serviceCreateInput);
454 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
455 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
456 .invoke(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 TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
468 rendererServiceWrapper)
469 .invoke(new TempServiceDeleteInputBuilder()
472 result.addListener(() -> endSignal.countDown(), executorService);
474 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
476 ResponseCodes.RESPONSE_FAILED,
477 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
479 LogMessages.SERVICE_NON_COMPLIANT,
480 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
484 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
485 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
486 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
487 rendererServiceWrapper)
488 .invoke(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, pathDescription);
502 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
503 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
504 rendererServiceWrapper)
505 .invoke(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
506 result.addListener(() -> endSignal.countDown(), executorService);
509 ResponseCodes.RESPONSE_OK,
510 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
514 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
515 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
516 new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
517 networkModelListenerImpl, pceServiceWrapper)
518 .invoke(new TempServiceCreateInputBuilder().build());
519 result.addListener(() -> endSignal.countDown(), executorService);
522 ResponseCodes.RESPONSE_FAILED,
523 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
527 void tempServiceCreateShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
528 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
529 when(serviceDSOperations.getTempService(any()))
530 .thenReturn(Optional.of(
531 new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.list
533 .setCommonId("bad_commonId")
535 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
536 new TempServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
537 networkModelListenerImpl, pceServiceWrapper)
538 .invoke(ServiceDataUtils.buildTempServiceCreateInput());
539 result.addListener(() -> endSignal.countDown(), executorService);
542 ResponseCodes.RESPONSE_FAILED,
543 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
545 "Service 'Temp (commonId)' already exists in datastore",
546 result.get().getResult().getConfigurationResponseCommon().getResponseMessage());
550 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
551 throws ExecutionException, InterruptedException {
552 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
553 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
554 new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
555 networkModelListenerImpl, pceServiceWrapper)
556 .invoke(ServiceDataUtils.buildTempServiceCreateInput());
557 result.addListener(() -> endSignal.countDown(), executorService);
560 ResponseCodes.RESPONSE_OK,
561 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
565 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
566 throws ExecutionException, InterruptedException {
567 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
568 new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
569 .invoke(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
571 ResponseCodes.RESPONSE_FAILED,
572 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
576 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
577 throws ExecutionException, InterruptedException {
578 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
579 new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
580 .invoke(new AddSpecificOperationalModesToCatalogInputBuilder().build());
582 ResponseCodes.RESPONSE_FAILED,
583 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
587 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
588 throws ExecutionException, InterruptedException {
589 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
590 new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
591 .invoke(CatalogDataUtils.buildAddORToCatalogInput());
593 ResponseCodes.RESPONSE_OK,
594 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
598 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
599 throws ExecutionException, InterruptedException {
600 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
601 new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
602 .invoke(CatalogDataUtils.buildAddSpecificToCatalogInput());
604 ResponseCodes.RESPONSE_OK,
605 result.get().getResult().getConfigurationResponseCommon().getResponseCode());