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.Assert.assertFalse;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.jupiter.api.Assertions.assertEquals;
13 import static org.junit.jupiter.api.Assertions.assertNull;
14 import static org.mockito.ArgumentMatchers.any;
15 import static org.mockito.Mockito.mock;
16 import static org.mockito.Mockito.times;
17 import static org.mockito.Mockito.verify;
18 import static org.mockito.Mockito.when;
19 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
21 import com.google.common.util.concurrent.Futures;
22 import com.google.common.util.concurrent.ListenableFuture;
23 import com.google.common.util.concurrent.ListeningExecutorService;
24 import com.google.common.util.concurrent.MoreExecutors;
26 import java.util.Optional;
27 import java.util.concurrent.CountDownLatch;
28 import java.util.concurrent.ExecutionException;
29 import java.util.concurrent.Executors;
30 import org.junit.Assert;
31 import org.junit.jupiter.api.BeforeEach;
32 import org.junit.jupiter.api.Test;
33 import org.junit.jupiter.api.extension.ExtendWith;
34 import org.mockito.Mock;
35 import org.mockito.junit.jupiter.MockitoExtension;
36 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
37 import org.opendaylight.mdsal.binding.api.RpcProviderService;
38 import org.opendaylight.transportpce.common.ResponseCodes;
39 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
40 import org.opendaylight.transportpce.pce.service.PathComputationService;
41 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
42 import org.opendaylight.transportpce.servicehandler.ServiceInput;
43 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
44 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
45 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
46 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
47 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
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.rev230925.PathComputationRequestOutputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRerouteRequestOutputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.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.ServiceSrlgGetInputBuilder;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceSrlgGetOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteOutput;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfoBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
89 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
90 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
91 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
92 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
93 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
94 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
95 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
96 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
97 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
98 import org.opendaylight.yangtools.yang.common.ErrorTag;
99 import org.opendaylight.yangtools.yang.common.ErrorType;
100 import org.opendaylight.yangtools.yang.common.RpcResult;
101 import org.opendaylight.yangtools.yang.common.Uint32;
103 @ExtendWith(MockitoExtension.class)
104 public class ServicehandlerImplTest extends AbstractTest {
106 private RpcProviderService rpcProviderService;
108 private PathComputationService pathComputationService;
110 private RendererServiceOperations rendererServiceOperations;
112 private NotificationPublishService notificationPublishService;
114 private PceListener pceListenerImpl;
116 private RendererListener rendererListenerImpl;
118 private NetworkListener networkModelListenerImpl;
121 private PathDescription pathDescription;
122 private ServiceDataStoreOperations serviceDataStoreOperations;
123 private CatalogDataStoreOperations catalogDataStoreOperations;
124 private ServiceCreateInput serviceCreateInput;
125 private ServiceDeleteInput serviceDeleteInput;
126 private ServiceReconfigureInput serviceReconfigureInput;
127 private ServiceRestorationInput serviceRestorationInput;
128 private ServiceRerouteInput serviceRerouteInput;
129 private ListeningExecutorService executorService;
130 private CountDownLatch endSignal;
131 private static final int NUM_THREADS = 5;
135 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
136 endSignal = new CountDownLatch(1);
137 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
138 this.catalogDataStoreOperations =
139 new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
140 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
141 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
142 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
143 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
144 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
145 pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
149 void testRpcRegistration() {
150 new ServicehandlerImpl(rpcProviderService,
151 pathComputationService, rendererServiceOperations, notificationPublishService,
152 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
153 serviceDataStoreOperations, catalogDataStoreOperations);
154 verify(rpcProviderService, times(1)).registerRpcImplementations(any());
158 void testNotImplementedRpc() throws InterruptedException, ExecutionException {
159 ListenableFuture<RpcResult<ServiceSrlgGetOutput>> result = new ServicehandlerImpl(rpcProviderService,
160 pathComputationService, rendererServiceOperations, notificationPublishService,
161 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
162 serviceDataStoreOperations, catalogDataStoreOperations)
163 .serviceSrlgGet(new ServiceSrlgGetInputBuilder().build());
164 result.addListener(() -> endSignal.countDown(), executorService);
166 assertNotNull(result.get());
167 assertFalse(result.get().isSuccessful());
168 assertNull(result.get().getResult());
169 assertEquals(ErrorType.RPC, result.get().getErrors().get(0).getErrorType());
170 assertEquals(ErrorSeverity.ERROR, result.get().getErrors().get(0).getSeverity());
171 assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, result.get().getErrors().get(0).getTag());
172 assertEquals("RPC not implemented yet", result.get().getErrors().get(0).getMessage());
176 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
177 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
178 new ServicehandlerImpl(rpcProviderService,
179 pathComputationService, rendererServiceOperations, notificationPublishService,
180 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
181 serviceDataStoreOperations, catalogDataStoreOperations)
182 .serviceCreate(new ServiceCreateInputBuilder().build());
183 result.addListener(() -> endSignal.countDown(), executorService);
186 ResponseCodes.RESPONSE_FAILED,
187 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
191 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
192 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
193 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
194 .thenReturn(Optional.of(
195 new ServicesBuilder()
196 .setServiceName(serviceCreateInput.getServiceName())
198 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
199 new ServicehandlerImpl(rpcProviderService,
200 pathComputationService, rendererServiceOperations, notificationPublishService,
201 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
202 serviceDSOperations, catalogDataStoreOperations)
203 .serviceCreate(serviceCreateInput);
204 result.addListener(() -> endSignal.countDown(), executorService);
207 ResponseCodes.RESPONSE_FAILED,
208 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
212 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
213 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
214 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
215 new ServicehandlerImpl(rpcProviderService,
216 pathComputationService, rendererServiceOperations, notificationPublishService,
217 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
218 serviceDataStoreOperations, catalogDataStoreOperations)
219 .serviceCreate(serviceCreateInput);
220 result.addListener(() -> endSignal.countDown(), executorService);
223 ResponseCodes.RESPONSE_OK,
224 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
228 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
229 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
230 new ServicehandlerImpl(rpcProviderService,
231 pathComputationService, rendererServiceOperations, notificationPublishService,
232 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
233 serviceDataStoreOperations, catalogDataStoreOperations)
235 new ServiceDeleteInputBuilder()
236 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
240 result.addListener(() -> endSignal.countDown(), executorService);
243 ResponseCodes.RESPONSE_FAILED,
244 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
248 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
249 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
250 new ServicehandlerImpl(rpcProviderService,
251 pathComputationService, rendererServiceOperations, notificationPublishService,
252 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
253 serviceDataStoreOperations, catalogDataStoreOperations)
254 .serviceDelete(serviceDeleteInput);
255 result.addListener(() -> endSignal.countDown(), executorService);
258 ResponseCodes.RESPONSE_FAILED,
259 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
263 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
264 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
265 serviceDataStoreOperations.createService(serviceCreateInput);
266 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
267 new ServicehandlerImpl(rpcProviderService,
268 pathComputationService, rendererServiceOperations, notificationPublishService,
269 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
270 serviceDataStoreOperations, catalogDataStoreOperations)
271 .serviceDelete(serviceDeleteInput);
272 result.addListener(() -> endSignal.countDown(), executorService);
275 ResponseCodes.RESPONSE_OK,
276 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
280 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
281 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(rpcProviderService, pathComputationService,
282 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
283 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
284 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
285 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
286 result.addListener(() -> endSignal.countDown(), executorService);
289 ResponseCodes.RESPONSE_FAILED,
290 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
294 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
295 throws ExecutionException, InterruptedException {
296 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
297 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
298 new ServicehandlerImpl(rpcProviderService,
299 pathComputationService, rendererServiceOperations, notificationPublishService,
300 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
301 serviceDataStoreOperations, catalogDataStoreOperations)
302 .serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
303 result.addListener(() -> endSignal.countDown(), executorService);
306 ResponseCodes.RESPONSE_OK,
307 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
311 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
312 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
313 new ServicehandlerImpl(rpcProviderService,
314 pathComputationService, rendererServiceOperations, notificationPublishService,
315 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
316 serviceDataStoreOperations, catalogDataStoreOperations)
317 .serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
318 result.addListener(() -> endSignal.countDown(), executorService);
324 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
325 //action -> service reconfigure
326 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
327 new ServicehandlerImpl(rpcProviderService,
328 pathComputationService, rendererServiceOperations, notificationPublishService,
329 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
330 serviceDataStoreOperations, catalogDataStoreOperations)
331 .serviceReconfigure(serviceReconfigureInput);
332 result.addListener(() -> endSignal.countDown(), executorService);
337 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
338 // serviceReconfigure is calling service delete method in renderer
339 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
340 //create service to reconfigure
341 serviceDataStoreOperations.createService(serviceCreateInput);
342 //service reconfigure test action
343 //ServiceReconfigureInput is created with the same service information that is created before
344 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
345 new ServicehandlerImpl(rpcProviderService,
346 pathComputationService, rendererServiceOperations, notificationPublishService,
347 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
348 serviceDataStoreOperations, catalogDataStoreOperations)
349 .serviceReconfigure(serviceReconfigureInput);
350 result.addListener(() -> endSignal.countDown(), executorService);
355 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
356 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
357 new ServicehandlerImpl(rpcProviderService,
358 pathComputationService, rendererServiceOperations, notificationPublishService,
359 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
360 serviceDataStoreOperations, catalogDataStoreOperations)
361 .serviceRestoration(new ServiceRestorationInputBuilder()
364 result.addListener(() -> endSignal.countDown(), executorService);
369 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
370 //action -> service restore
371 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
372 new ServicehandlerImpl(rpcProviderService,
373 pathComputationService, rendererServiceOperations, notificationPublishService,
374 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
375 serviceDataStoreOperations, catalogDataStoreOperations)
376 .serviceRestoration(serviceRestorationInput);
377 result.addListener(() -> endSignal.countDown(), executorService);
382 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
383 // serviceRestoration is calling service delete method in renderer
384 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
385 //create service to restore
386 serviceDataStoreOperations.createService(serviceCreateInput);
387 //service Restoration test action
388 //ServiceRestorationInput is created with the same service information that is created before
389 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
390 new ServicehandlerImpl(rpcProviderService,
391 pathComputationService, rendererServiceOperations, notificationPublishService,
392 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
393 serviceDataStoreOperations, catalogDataStoreOperations)
394 .serviceRestoration(serviceRestorationInput);
395 result.addListener(() -> endSignal.countDown(), executorService);
400 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
401 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
402 new ServicehandlerImpl(rpcProviderService,
403 pathComputationService, rendererServiceOperations, notificationPublishService,
404 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
405 serviceDataStoreOperations, catalogDataStoreOperations)
406 .serviceReroute(new ServiceRerouteInputBuilder()
409 result.addListener(() -> endSignal.countDown(), executorService);
412 ResponseCodes.RESPONSE_FAILED,
413 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
417 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
418 //action -> service reconfigure
419 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
420 new ServicehandlerImpl(rpcProviderService,
421 pathComputationService, rendererServiceOperations, notificationPublishService,
422 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
423 serviceDataStoreOperations, catalogDataStoreOperations)
424 .serviceReroute(serviceRerouteInput);
425 result.addListener(() -> endSignal.countDown(), executorService);
428 ResponseCodes.RESPONSE_FAILED,
429 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
433 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
434 when(pathComputationService.pathComputationRerouteRequest(any()))
435 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
436 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
437 .setResponseCode(ResponseCodes.RESPONSE_OK)
440 Map<AToZKey, AToZ> atoz = Map.of(
444 .setResource(new ResourceBuilder()
445 .setResource(new TerminationPointBuilder()
446 .setTpNodeId("tpNodeIdC")
449 .setState(State.InService)
455 .setResource(new ResourceBuilder()
456 .setResource(new TerminationPointBuilder()
457 .setTpNodeId("tpNodeIdD")
460 .setState(State.InService)
462 .build(), new AToZKey("2"),
465 .setResource(new ResourceBuilder()
466 .setResource(new TerminationPointBuilder()
467 .setTpNodeId("tpNodeIdA")
470 .setState(State.InService)
475 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
476 new PathComputationRequestOutputBuilder()
477 .setResponseParameters(new ResponseParametersBuilder()
478 .setPathDescription(new PathDescriptionBuilder()
479 .setAToZDirection(new AToZDirectionBuilder()
481 .setRate(Uint32.valueOf(1))
483 .setZToADirection(new ZToADirectionBuilder()
484 .setRate(Uint32.valueOf(1))
489 serviceDataStoreOperations.createService(serviceCreateInput);
490 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
491 new ServicehandlerImpl(rpcProviderService,
492 pathComputationService, rendererServiceOperations, notificationPublishService,
493 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
494 serviceDataStoreOperations, catalogDataStoreOperations)
495 .serviceReroute(serviceRerouteInput);
496 result.addListener(() -> endSignal.countDown(), executorService);
499 ResponseCodes.RESPONSE_OK,
500 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
504 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
505 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
506 new ServicehandlerImpl(rpcProviderService,
507 pathComputationService, rendererServiceOperations, notificationPublishService,
508 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
509 serviceDataStoreOperations, catalogDataStoreOperations)
510 .tempServiceDelete(new TempServiceDeleteInputBuilder()
513 result.addListener(() -> endSignal.countDown(), executorService);
515 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
517 ResponseCodes.RESPONSE_FAILED,
518 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
520 LogMessages.SERVICE_NON_COMPLIANT,
521 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
525 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
526 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
527 new ServicehandlerImpl(rpcProviderService,
528 pathComputationService, rendererServiceOperations, notificationPublishService,
529 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
530 serviceDataStoreOperations, catalogDataStoreOperations)
531 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput());
532 result.addListener(() -> endSignal.countDown(), executorService);
535 ResponseCodes.RESPONSE_FAILED,
536 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
540 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
541 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
542 //create temp service to delete in the temp delete action
543 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
544 serviceDataStoreOperations.createTempService(createInput, pathDescription);
545 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
546 new ServicehandlerImpl(rpcProviderService,
547 pathComputationService, rendererServiceOperations, notificationPublishService,
548 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
549 serviceDataStoreOperations, catalogDataStoreOperations)
550 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
551 result.addListener(() -> endSignal.countDown(), executorService);
554 ResponseCodes.RESPONSE_OK,
555 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
559 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
560 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
561 new ServicehandlerImpl(rpcProviderService,
562 pathComputationService, rendererServiceOperations, notificationPublishService,
563 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
564 serviceDataStoreOperations, catalogDataStoreOperations)
565 .tempServiceCreate(new TempServiceCreateInputBuilder().build());
566 result.addListener(() -> endSignal.countDown(), executorService);
569 ResponseCodes.RESPONSE_FAILED,
570 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
574 void tempServiceCreateShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
575 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
576 when(serviceDSOperations.getTempService(any()))
577 .thenReturn(Optional.of(
578 new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.list
580 .setCommonId("bad_commonId")
582 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
583 new ServicehandlerImpl(rpcProviderService,
584 pathComputationService, rendererServiceOperations, notificationPublishService,
585 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
586 serviceDSOperations, catalogDataStoreOperations)
587 .tempServiceCreate(ServiceDataUtils.buildTempServiceCreateInput());
588 result.addListener(() -> endSignal.countDown(), executorService);
591 ResponseCodes.RESPONSE_FAILED,
592 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
594 "Service 'Temp (commonId)' already exists in datastore",
595 result.get().getResult().getConfigurationResponseCommon().getResponseMessage());
599 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
600 throws ExecutionException, InterruptedException {
601 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
602 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
603 new ServicehandlerImpl(rpcProviderService,
604 pathComputationService, rendererServiceOperations, notificationPublishService,
605 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
606 serviceDataStoreOperations, catalogDataStoreOperations)
607 .tempServiceCreate(ServiceDataUtils.buildTempServiceCreateInput());
608 result.addListener(() -> endSignal.countDown(), executorService);
611 ResponseCodes.RESPONSE_OK,
612 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
616 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
617 throws ExecutionException, InterruptedException {
618 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
619 new ServicehandlerImpl(rpcProviderService,
620 pathComputationService, rendererServiceOperations, notificationPublishService,
621 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
622 serviceDataStoreOperations, catalogDataStoreOperations)
623 .addOpenroadmOperationalModesToCatalog(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
625 ResponseCodes.RESPONSE_FAILED,
626 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
630 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
631 throws ExecutionException, InterruptedException {
632 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
633 new ServicehandlerImpl(rpcProviderService,
634 pathComputationService, rendererServiceOperations, notificationPublishService,
635 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
636 serviceDataStoreOperations, catalogDataStoreOperations)
637 .addSpecificOperationalModesToCatalog(new AddSpecificOperationalModesToCatalogInputBuilder().build());
639 ResponseCodes.RESPONSE_FAILED,
640 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
644 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
645 throws ExecutionException, InterruptedException {
646 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
647 new ServicehandlerImpl(rpcProviderService,
648 pathComputationService, rendererServiceOperations, notificationPublishService,
649 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
650 serviceDataStoreOperations, catalogDataStoreOperations)
651 .addOpenroadmOperationalModesToCatalog(CatalogDataUtils.buildAddORToCatalogInput());
653 ResponseCodes.RESPONSE_OK,
654 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
658 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
659 throws ExecutionException, InterruptedException {
660 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
661 new ServicehandlerImpl(rpcProviderService,
662 pathComputationService, rendererServiceOperations, notificationPublishService,
663 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
664 serviceDataStoreOperations, catalogDataStoreOperations)
665 .addSpecificOperationalModesToCatalog(CatalogDataUtils.buildAddSpecificToCatalogInput());
667 ResponseCodes.RESPONSE_OK,
668 result.get().getResult().getConfigurationResponseCommon().getResponseCode());