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.ServiceDataStoreOperations;
46 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
47 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
48 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
49 import org.opendaylight.transportpce.test.AbstractTest;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInputBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogOutput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInputBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInputBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfoBuilder;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
84 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
89 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
90 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
91 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
92 import org.opendaylight.yangtools.yang.common.RpcResult;
93 import org.opendaylight.yangtools.yang.common.Uint32;
95 @ExtendWith(MockitoExtension.class)
96 public class ServicehandlerImplTest extends AbstractTest {
99 private RpcProviderService rpcProviderService;
101 private PathComputationService pathComputationService;
103 private RendererServiceOperations rendererServiceOperations;
105 private NotificationPublishService notificationPublishService;
107 private PceListener pceListenerImpl;
109 private RendererListener rendererListenerImpl;
111 private NetworkListener networkModelListenerImpl;
114 private PathDescription pathDescription;
115 private ServiceDataStoreOperations serviceDataStoreOperations;
116 private CatalogDataStoreOperations catalogDataStoreOperations;
117 private ServiceCreateInput serviceCreateInput;
118 private ServiceDeleteInput serviceDeleteInput;
119 private ServiceReconfigureInput serviceReconfigureInput;
120 private ServiceRestorationInput serviceRestorationInput;
121 private ServiceRerouteInput serviceRerouteInput;
122 private ListeningExecutorService executorService;
123 private CountDownLatch endSignal;
124 private static final int NUM_THREADS = 5;
128 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
129 endSignal = new CountDownLatch(1);
130 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
131 this.catalogDataStoreOperations =
132 new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
133 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
134 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
135 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
136 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
137 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
138 pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
142 void testRpcRegistration() {
143 new ServicehandlerImpl(rpcProviderService,
144 pathComputationService, rendererServiceOperations, notificationPublishService,
145 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
146 serviceDataStoreOperations, catalogDataStoreOperations);
147 verify(rpcProviderService, times(1)).registerRpcImplementations(any());
151 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
152 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
153 new ServicehandlerImpl(rpcProviderService,
154 pathComputationService, rendererServiceOperations, notificationPublishService,
155 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
156 serviceDataStoreOperations, catalogDataStoreOperations)
157 .serviceCreate(new ServiceCreateInputBuilder().build());
158 result.addListener(() -> endSignal.countDown(), executorService);
161 ResponseCodes.RESPONSE_FAILED,
162 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
166 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
167 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
168 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
169 .thenReturn(Optional.of(
170 new ServicesBuilder()
171 .setServiceName(serviceCreateInput.getServiceName())
173 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
174 new ServicehandlerImpl(rpcProviderService,
175 pathComputationService, rendererServiceOperations, notificationPublishService,
176 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
177 serviceDSOperations, catalogDataStoreOperations)
178 .serviceCreate(serviceCreateInput);
179 result.addListener(() -> endSignal.countDown(), executorService);
182 ResponseCodes.RESPONSE_FAILED,
183 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
187 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
188 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
189 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
190 new ServicehandlerImpl(rpcProviderService,
191 pathComputationService, rendererServiceOperations, notificationPublishService,
192 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
193 serviceDataStoreOperations, catalogDataStoreOperations)
194 .serviceCreate(serviceCreateInput);
195 result.addListener(() -> endSignal.countDown(), executorService);
198 ResponseCodes.RESPONSE_OK,
199 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
203 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
204 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
205 new ServicehandlerImpl(rpcProviderService,
206 pathComputationService, rendererServiceOperations, notificationPublishService,
207 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
208 serviceDataStoreOperations, catalogDataStoreOperations)
210 new ServiceDeleteInputBuilder()
211 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
215 result.addListener(() -> endSignal.countDown(), executorService);
218 ResponseCodes.RESPONSE_FAILED,
219 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
223 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
224 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
225 new ServicehandlerImpl(rpcProviderService,
226 pathComputationService, rendererServiceOperations, notificationPublishService,
227 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
228 serviceDataStoreOperations, catalogDataStoreOperations)
229 .serviceDelete(serviceDeleteInput);
230 result.addListener(() -> endSignal.countDown(), executorService);
233 ResponseCodes.RESPONSE_FAILED,
234 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
238 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
239 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
240 serviceDataStoreOperations.createService(serviceCreateInput);
241 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
242 new ServicehandlerImpl(rpcProviderService,
243 pathComputationService, rendererServiceOperations, notificationPublishService,
244 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
245 serviceDataStoreOperations, catalogDataStoreOperations)
246 .serviceDelete(serviceDeleteInput);
247 result.addListener(() -> endSignal.countDown(), executorService);
250 ResponseCodes.RESPONSE_OK,
251 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
255 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
256 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(rpcProviderService, pathComputationService,
257 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
258 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
259 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
260 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
261 result.addListener(() -> endSignal.countDown(), executorService);
264 ResponseCodes.RESPONSE_FAILED,
265 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
269 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
270 throws ExecutionException, InterruptedException {
271 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
272 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
273 new ServicehandlerImpl(rpcProviderService,
274 pathComputationService, rendererServiceOperations, notificationPublishService,
275 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
276 serviceDataStoreOperations, catalogDataStoreOperations)
277 .serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
278 result.addListener(() -> endSignal.countDown(), executorService);
281 ResponseCodes.RESPONSE_OK,
282 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
286 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
287 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
288 new ServicehandlerImpl(rpcProviderService,
289 pathComputationService, rendererServiceOperations, notificationPublishService,
290 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
291 serviceDataStoreOperations, catalogDataStoreOperations)
292 .serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
293 result.addListener(() -> endSignal.countDown(), executorService);
299 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
300 //action -> service reconfigure
301 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
302 new ServicehandlerImpl(rpcProviderService,
303 pathComputationService, rendererServiceOperations, notificationPublishService,
304 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
305 serviceDataStoreOperations, catalogDataStoreOperations)
306 .serviceReconfigure(serviceReconfigureInput);
307 result.addListener(() -> endSignal.countDown(), executorService);
312 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
313 // serviceReconfigure is calling service delete method in renderer
314 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
315 //create service to reconfigure
316 serviceDataStoreOperations.createService(serviceCreateInput);
317 //service reconfigure test action
318 //ServiceReconfigureInput is created with the same service information that is created before
319 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
320 new ServicehandlerImpl(rpcProviderService,
321 pathComputationService, rendererServiceOperations, notificationPublishService,
322 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
323 serviceDataStoreOperations, catalogDataStoreOperations)
324 .serviceReconfigure(serviceReconfigureInput);
325 result.addListener(() -> endSignal.countDown(), executorService);
330 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
331 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
332 new ServicehandlerImpl(rpcProviderService,
333 pathComputationService, rendererServiceOperations, notificationPublishService,
334 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
335 serviceDataStoreOperations, catalogDataStoreOperations)
336 .serviceRestoration(new ServiceRestorationInputBuilder()
339 result.addListener(() -> endSignal.countDown(), executorService);
344 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
345 //action -> service restore
346 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
347 new ServicehandlerImpl(rpcProviderService,
348 pathComputationService, rendererServiceOperations, notificationPublishService,
349 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
350 serviceDataStoreOperations, catalogDataStoreOperations)
351 .serviceRestoration(serviceRestorationInput);
352 result.addListener(() -> endSignal.countDown(), executorService);
357 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
358 // serviceRestoration is calling service delete method in renderer
359 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
360 //create service to restore
361 serviceDataStoreOperations.createService(serviceCreateInput);
362 //service Restoration test action
363 //ServiceRestorationInput is created with the same service information that is created before
364 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
365 new ServicehandlerImpl(rpcProviderService,
366 pathComputationService, rendererServiceOperations, notificationPublishService,
367 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
368 serviceDataStoreOperations, catalogDataStoreOperations)
369 .serviceRestoration(serviceRestorationInput);
370 result.addListener(() -> endSignal.countDown(), executorService);
375 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
376 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
377 new ServicehandlerImpl(rpcProviderService,
378 pathComputationService, rendererServiceOperations, notificationPublishService,
379 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
380 serviceDataStoreOperations, catalogDataStoreOperations)
381 .serviceReroute(new ServiceRerouteInputBuilder()
384 result.addListener(() -> endSignal.countDown(), executorService);
387 ResponseCodes.RESPONSE_FAILED,
388 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
392 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
393 //action -> service reconfigure
394 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
395 new ServicehandlerImpl(rpcProviderService,
396 pathComputationService, rendererServiceOperations, notificationPublishService,
397 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
398 serviceDataStoreOperations, catalogDataStoreOperations)
399 .serviceReroute(serviceRerouteInput);
400 result.addListener(() -> endSignal.countDown(), executorService);
403 ResponseCodes.RESPONSE_FAILED,
404 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
408 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
409 when(pathComputationService.pathComputationRerouteRequest(any()))
410 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
411 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
412 .setResponseCode(ResponseCodes.RESPONSE_OK)
415 Map<AToZKey, AToZ> atoz = Map.of(
419 .setResource(new ResourceBuilder()
420 .setResource(new TerminationPointBuilder()
421 .setTpNodeId("tpNodeIdC")
424 .setState(State.InService)
430 .setResource(new ResourceBuilder()
431 .setResource(new TerminationPointBuilder()
432 .setTpNodeId("tpNodeIdD")
435 .setState(State.InService)
437 .build(), new AToZKey("2"),
440 .setResource(new ResourceBuilder()
441 .setResource(new TerminationPointBuilder()
442 .setTpNodeId("tpNodeIdA")
445 .setState(State.InService)
450 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
451 new PathComputationRequestOutputBuilder()
452 .setResponseParameters(new ResponseParametersBuilder()
453 .setPathDescription(new PathDescriptionBuilder()
454 .setAToZDirection(new AToZDirectionBuilder()
456 .setRate(Uint32.valueOf(1))
458 .setZToADirection(new ZToADirectionBuilder()
459 .setRate(Uint32.valueOf(1))
464 serviceDataStoreOperations.createService(serviceCreateInput);
465 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
466 new ServicehandlerImpl(rpcProviderService,
467 pathComputationService, rendererServiceOperations, notificationPublishService,
468 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
469 serviceDataStoreOperations, catalogDataStoreOperations)
470 .serviceReroute(serviceRerouteInput);
471 result.addListener(() -> endSignal.countDown(), executorService);
474 ResponseCodes.RESPONSE_OK,
475 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
479 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
480 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
481 new ServicehandlerImpl(rpcProviderService,
482 pathComputationService, rendererServiceOperations, notificationPublishService,
483 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
484 serviceDataStoreOperations, catalogDataStoreOperations)
485 .tempServiceDelete(new TempServiceDeleteInputBuilder()
488 result.addListener(() -> endSignal.countDown(), executorService);
490 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
492 ResponseCodes.RESPONSE_FAILED,
493 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
495 LogMessages.SERVICE_NON_COMPLIANT,
496 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
500 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
501 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
502 new ServicehandlerImpl(rpcProviderService,
503 pathComputationService, rendererServiceOperations, notificationPublishService,
504 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
505 serviceDataStoreOperations, catalogDataStoreOperations)
506 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput());
507 result.addListener(() -> endSignal.countDown(), executorService);
510 ResponseCodes.RESPONSE_FAILED,
511 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
515 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
516 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
517 //create temp service to delete in the temp delete action
518 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
519 serviceDataStoreOperations.createTempService(createInput, pathDescription);
520 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
521 new ServicehandlerImpl(rpcProviderService,
522 pathComputationService, rendererServiceOperations, notificationPublishService,
523 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
524 serviceDataStoreOperations, catalogDataStoreOperations)
525 .tempServiceDelete(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
526 result.addListener(() -> endSignal.countDown(), executorService);
529 ResponseCodes.RESPONSE_OK,
530 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
534 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
535 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
536 new ServicehandlerImpl(rpcProviderService,
537 pathComputationService, rendererServiceOperations, notificationPublishService,
538 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
539 serviceDataStoreOperations, catalogDataStoreOperations)
540 .tempServiceCreate(new TempServiceCreateInputBuilder().build());
541 result.addListener(() -> endSignal.countDown(), executorService);
544 ResponseCodes.RESPONSE_FAILED,
545 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
549 void tempServiceCreateShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
550 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
551 when(serviceDSOperations.getTempService(any()))
552 .thenReturn(Optional.of(
553 new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.list
555 .setCommonId("bad_commonId")
557 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
558 new ServicehandlerImpl(rpcProviderService,
559 pathComputationService, rendererServiceOperations, notificationPublishService,
560 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
561 serviceDSOperations, catalogDataStoreOperations)
562 .tempServiceCreate(ServiceDataUtils.buildTempServiceCreateInput());
563 result.addListener(() -> endSignal.countDown(), executorService);
566 ResponseCodes.RESPONSE_FAILED,
567 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
569 "Service 'Temp (commonId)' already exists in datastore",
570 result.get().getResult().getConfigurationResponseCommon().getResponseMessage());
574 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
575 throws ExecutionException, InterruptedException {
576 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
577 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
578 new ServicehandlerImpl(rpcProviderService,
579 pathComputationService, rendererServiceOperations, notificationPublishService,
580 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
581 serviceDataStoreOperations, catalogDataStoreOperations)
582 .tempServiceCreate(ServiceDataUtils.buildTempServiceCreateInput());
583 result.addListener(() -> endSignal.countDown(), executorService);
586 ResponseCodes.RESPONSE_OK,
587 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
591 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
592 throws ExecutionException, InterruptedException {
593 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
594 new ServicehandlerImpl(rpcProviderService,
595 pathComputationService, rendererServiceOperations, notificationPublishService,
596 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
597 serviceDataStoreOperations, catalogDataStoreOperations)
598 .addOpenroadmOperationalModesToCatalog(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
600 ResponseCodes.RESPONSE_FAILED,
601 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
605 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
606 throws ExecutionException, InterruptedException {
607 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
608 new ServicehandlerImpl(rpcProviderService,
609 pathComputationService, rendererServiceOperations, notificationPublishService,
610 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
611 serviceDataStoreOperations, catalogDataStoreOperations)
612 .addSpecificOperationalModesToCatalog(new AddSpecificOperationalModesToCatalogInputBuilder().build());
614 ResponseCodes.RESPONSE_FAILED,
615 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
619 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
620 throws ExecutionException, InterruptedException {
621 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
622 new ServicehandlerImpl(rpcProviderService,
623 pathComputationService, rendererServiceOperations, notificationPublishService,
624 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
625 serviceDataStoreOperations, catalogDataStoreOperations)
626 .addOpenroadmOperationalModesToCatalog(CatalogDataUtils.buildAddORToCatalogInput());
628 ResponseCodes.RESPONSE_OK,
629 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
633 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
634 throws ExecutionException, InterruptedException {
635 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
636 new ServicehandlerImpl(rpcProviderService,
637 pathComputationService, rendererServiceOperations, notificationPublishService,
638 pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
639 serviceDataStoreOperations, catalogDataStoreOperations)
640 .addSpecificOperationalModesToCatalog(CatalogDataUtils.buildAddSpecificToCatalogInput());
642 ResponseCodes.RESPONSE_OK,
643 result.get().getResult().getConfigurationResponseCommon().getResponseCode());