2 * Copyright © 2019 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.servicehandler.impl;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.Mockito.mock;
13 import static org.mockito.Mockito.times;
14 import static org.mockito.Mockito.verify;
15 import static org.mockito.Mockito.when;
16 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
18 import com.google.common.collect.ClassToInstanceMap;
19 import com.google.common.util.concurrent.Futures;
20 import com.google.common.util.concurrent.ListenableFuture;
21 import com.google.common.util.concurrent.ListeningExecutorService;
22 import com.google.common.util.concurrent.MoreExecutors;
24 import java.util.Optional;
25 import java.util.concurrent.CountDownLatch;
26 import java.util.concurrent.ExecutionException;
27 import java.util.concurrent.Executors;
28 import org.junit.Assert;
29 import org.junit.jupiter.api.BeforeEach;
30 import org.junit.jupiter.api.Test;
31 import org.junit.jupiter.api.extension.ExtendWith;
32 import org.mockito.Mock;
33 import org.mockito.junit.jupiter.MockitoExtension;
34 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
35 import org.opendaylight.mdsal.binding.api.RpcProviderService;
36 import org.opendaylight.transportpce.common.ResponseCodes;
37 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
38 import org.opendaylight.transportpce.pce.service.PathComputationService;
39 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
40 import org.opendaylight.transportpce.servicehandler.ServiceInput;
41 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
42 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
43 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
44 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
45 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
46 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
47 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
48 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
49 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
50 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
51 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
52 import org.opendaylight.transportpce.test.AbstractTest;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.service.path.rpc.result.PathDescription;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogInputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddOpenroadmOperationalModesToCatalogOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.AddSpecificOperationalModesToCatalogOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckInputBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceFeasibilityCheckOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureInputBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReconfigureOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInputBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteOutput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.delete.input.ServiceDeleteReqInfoBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
89 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
90 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
91 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
92 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
93 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
94 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
95 import org.opendaylight.yangtools.yang.common.RpcResult;
96 import org.opendaylight.yangtools.yang.common.Uint32;
98 @ExtendWith(MockitoExtension.class)
99 public class ServicehandlerImplTest extends AbstractTest {
101 private RpcProviderService rpcProviderService;
103 private PathComputationService pathComputationService;
105 private RendererServiceOperations rendererServiceOperations;
107 private NotificationPublishService notificationPublishService;
109 private PceListener pceListenerImpl;
111 private RendererListener rendererListenerImpl;
113 private NetworkListener networkModelListenerImpl;
116 private PathDescription pathDescription;
117 private ServiceDataStoreOperations serviceDataStoreOperations;
118 private CatalogDataStoreOperations catalogDataStoreOperations;
119 private ServiceCreateInput serviceCreateInput;
120 private ServiceDeleteInput serviceDeleteInput;
121 private ServiceReconfigureInput serviceReconfigureInput;
122 private ServiceRestorationInput serviceRestorationInput;
123 private ServiceRerouteInput serviceRerouteInput;
124 private ListeningExecutorService executorService;
125 private CountDownLatch endSignal;
126 private static final int NUM_THREADS = 5;
127 private PCEServiceWrapper pceServiceWrapper;
128 private RendererServiceWrapper rendererServiceWrapper;
132 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
133 endSignal = new CountDownLatch(1);
134 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
135 this.catalogDataStoreOperations =
136 new CatalogDataStoreOperationsImpl(new NetworkTransactionImpl(getDataBroker()));
137 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
138 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
139 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
140 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
141 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
142 pathDescription = ServiceDataUtils.createPathDescription(0,1,0,1);
143 pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
144 this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
148 void testRpcRegistration() {
149 new ServicehandlerImpl(rpcProviderService, serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
150 networkModelListenerImpl, catalogDataStoreOperations, pathComputationService, rendererServiceOperations,
151 notificationPublishService);
152 verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
156 // void testNotImplementedRpc() throws InterruptedException, ExecutionException {
157 // ListenableFuture<RpcResult<ServiceSrlgGetOutput>> result = new ServicehandlerImpl(rpcProviderService,
158 // serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
159 // catalogDataStoreOperations, pathComputationService, rendererServiceOperations,
160 // notificationPublishService)
161 // .serviceSrlgGet(new ServiceSrlgGetInputBuilder().build());
163 // result.addListener(() -> endSignal.countDown(), executorService);
164 // endSignal.await();
165 // assertNotNull(result.get());
166 // assertFalse(result.get().isSuccessful());
167 // assertNull(result.get().getResult());
168 // assertEquals(ErrorType.RPC, result.get().getErrors().get(0).getErrorType());
169 // assertEquals(ErrorSeverity.ERROR, result.get().getErrors().get(0).getSeverity());
170 // assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, result.get().getErrors().get(0).getTag());
171 // assertEquals("RPC not implemented yet", result.get().getErrors().get(0).getMessage());
175 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
176 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
177 new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
178 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
179 .invoke(new ServiceCreateInputBuilder().build());
180 result.addListener(() -> endSignal.countDown(), executorService);
183 ResponseCodes.RESPONSE_FAILED,
184 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
188 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
189 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
190 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
191 .thenReturn(Optional.of(
192 new ServicesBuilder()
193 .setServiceName(serviceCreateInput.getServiceName())
195 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
196 new ServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
197 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
198 .invoke(serviceCreateInput);
199 result.addListener(() -> endSignal.countDown(), executorService);
202 ResponseCodes.RESPONSE_FAILED,
203 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
207 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful() throws ExecutionException, InterruptedException {
208 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
209 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
210 new ServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
211 networkModelListenerImpl, pceServiceWrapper, notificationPublishService)
212 .invoke(serviceCreateInput);
213 result.addListener(() -> endSignal.countDown(), executorService);
216 ResponseCodes.RESPONSE_OK,
217 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
221 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
222 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
223 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
224 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
225 .invoke(new ServiceDeleteInputBuilder()
226 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
230 result.addListener(() -> endSignal.countDown(), executorService);
233 ResponseCodes.RESPONSE_FAILED,
234 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
238 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
239 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
240 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
241 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
242 .invoke(serviceDeleteInput);
243 result.addListener(() -> endSignal.countDown(), executorService);
246 ResponseCodes.RESPONSE_FAILED,
247 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
251 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
252 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
253 serviceDataStoreOperations.createService(serviceCreateInput);
254 ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
255 new ServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
256 networkModelListenerImpl, rendererServiceWrapper, notificationPublishService)
257 .invoke(serviceDeleteInput);
258 result.addListener(() -> endSignal.countDown(), executorService);
261 ResponseCodes.RESPONSE_OK,
262 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
266 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
267 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
268 new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
269 networkModelListenerImpl, pceServiceWrapper)
270 .invoke(new ServiceFeasibilityCheckInputBuilder().build());
271 result.addListener(() -> endSignal.countDown(), executorService);
274 ResponseCodes.RESPONSE_FAILED,
275 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
279 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
280 throws ExecutionException, InterruptedException {
281 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
282 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
283 new ServiceFeasibilityCheckImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
284 networkModelListenerImpl, pceServiceWrapper)
285 .invoke(ServiceDataUtils.buildServiceFeasibilityCheckInput());
286 result.addListener(() -> endSignal.countDown(), executorService);
289 ResponseCodes.RESPONSE_OK,
290 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
294 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
295 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
296 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
297 networkModelListenerImpl, rendererServiceWrapper)
298 .invoke(new ServiceReconfigureInputBuilder().setServiceName("").build());
299 result.addListener(() -> endSignal.countDown(), executorService);
305 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
306 //action -> service reconfigure
307 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
308 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
309 networkModelListenerImpl, rendererServiceWrapper)
310 .invoke(serviceReconfigureInput);
311 result.addListener(() -> endSignal.countDown(), executorService);
316 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
317 // serviceReconfigure is calling service delete method in renderer
318 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
319 //create service to reconfigure
320 serviceDataStoreOperations.createService(serviceCreateInput);
321 //service reconfigure test action
322 //ServiceReconfigureInput is created with the same service information that is created before
323 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
324 new ServiceReconfigureImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
325 networkModelListenerImpl, rendererServiceWrapper)
326 .invoke(serviceReconfigureInput);
327 result.addListener(() -> endSignal.countDown(), executorService);
332 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
333 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
334 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
335 networkModelListenerImpl, rendererServiceWrapper)
336 .invoke(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 ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
348 networkModelListenerImpl, rendererServiceWrapper)
349 .invoke(serviceRestorationInput);
350 result.addListener(() -> endSignal.countDown(), executorService);
355 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
356 // serviceRestoration is calling service delete method in renderer
357 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
358 //create service to restore
359 serviceDataStoreOperations.createService(serviceCreateInput);
360 //service Restoration test action
361 //ServiceRestorationInput is created with the same service information that is created before
362 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
363 new ServiceRestorationImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
364 networkModelListenerImpl, rendererServiceWrapper)
365 .invoke(serviceRestorationInput);
366 result.addListener(() -> endSignal.countDown(), executorService);
371 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
372 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
373 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
374 .invoke(new ServiceRerouteInputBuilder()
377 result.addListener(() -> endSignal.countDown(), executorService);
380 ResponseCodes.RESPONSE_FAILED,
381 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
385 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
386 //action -> service reconfigure
387 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
388 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
389 .invoke(serviceRerouteInput);
390 result.addListener(() -> endSignal.countDown(), executorService);
393 ResponseCodes.RESPONSE_FAILED,
394 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
398 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
399 when(pathComputationService.pathComputationRerouteRequest(any()))
400 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
401 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
402 .setResponseCode(ResponseCodes.RESPONSE_OK)
405 Map<AToZKey, AToZ> atoz = Map.of(
409 .setResource(new ResourceBuilder()
410 .setResource(new TerminationPointBuilder()
411 .setTpNodeId("tpNodeIdC")
414 .setState(State.InService)
420 .setResource(new ResourceBuilder()
421 .setResource(new TerminationPointBuilder()
422 .setTpNodeId("tpNodeIdD")
425 .setState(State.InService)
427 .build(), new AToZKey("2"),
430 .setResource(new ResourceBuilder()
431 .setResource(new TerminationPointBuilder()
432 .setTpNodeId("tpNodeIdA")
435 .setState(State.InService)
440 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
441 new PathComputationRequestOutputBuilder()
442 .setResponseParameters(new ResponseParametersBuilder()
443 .setPathDescription(new PathDescriptionBuilder()
444 .setAToZDirection(new AToZDirectionBuilder()
446 .setRate(Uint32.valueOf(1))
448 .setZToADirection(new ZToADirectionBuilder()
449 .setRate(Uint32.valueOf(1))
454 serviceDataStoreOperations.createService(serviceCreateInput);
455 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
456 new ServiceRerouteImpl(serviceDataStoreOperations, pceServiceWrapper)
457 .invoke(serviceRerouteInput);
458 result.addListener(() -> endSignal.countDown(), executorService);
461 ResponseCodes.RESPONSE_OK,
462 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
466 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
467 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
468 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
469 rendererServiceWrapper)
470 .invoke(new TempServiceDeleteInputBuilder()
473 result.addListener(() -> endSignal.countDown(), executorService);
475 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
477 ResponseCodes.RESPONSE_FAILED,
478 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
480 LogMessages.SERVICE_NON_COMPLIANT,
481 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
485 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
486 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
487 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
488 rendererServiceWrapper)
489 .invoke(ServiceDataUtils.buildTempServiceDeleteInput());
490 result.addListener(() -> endSignal.countDown(), executorService);
493 ResponseCodes.RESPONSE_FAILED,
494 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
498 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
499 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
500 //create temp service to delete in the temp delete action
501 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
502 serviceDataStoreOperations.createTempService(createInput, pathDescription);
503 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
504 new TempServiceDeleteImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
505 rendererServiceWrapper)
506 .invoke(ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId()));
507 result.addListener(() -> endSignal.countDown(), executorService);
510 ResponseCodes.RESPONSE_OK,
511 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
515 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
516 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
517 new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
518 networkModelListenerImpl, pceServiceWrapper)
519 .invoke(new TempServiceCreateInputBuilder().build());
520 result.addListener(() -> endSignal.countDown(), executorService);
523 ResponseCodes.RESPONSE_FAILED,
524 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
528 void tempServiceCreateShouldBeFailedWithServiceAlreadyExist() throws ExecutionException, InterruptedException {
529 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
530 when(serviceDSOperations.getTempService(any()))
531 .thenReturn(Optional.of(
532 new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.temp.service.list
534 .setCommonId("bad_commonId")
536 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
537 new TempServiceCreateImpl(serviceDSOperations, pceListenerImpl, rendererListenerImpl,
538 networkModelListenerImpl, pceServiceWrapper)
539 .invoke(ServiceDataUtils.buildTempServiceCreateInput());
540 result.addListener(() -> endSignal.countDown(), executorService);
543 ResponseCodes.RESPONSE_FAILED,
544 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
546 "Service 'Temp (commonId)' already exists in datastore",
547 result.get().getResult().getConfigurationResponseCommon().getResponseMessage());
551 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
552 throws ExecutionException, InterruptedException {
553 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
554 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
555 new TempServiceCreateImpl(serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl,
556 networkModelListenerImpl, pceServiceWrapper)
557 .invoke(ServiceDataUtils.buildTempServiceCreateInput());
558 result.addListener(() -> endSignal.countDown(), executorService);
561 ResponseCodes.RESPONSE_OK,
562 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
566 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput()
567 throws ExecutionException, InterruptedException {
568 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
569 new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
570 .invoke(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
572 ResponseCodes.RESPONSE_FAILED,
573 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
577 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput()
578 throws ExecutionException, InterruptedException {
579 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
580 new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
581 .invoke(new AddSpecificOperationalModesToCatalogInputBuilder().build());
583 ResponseCodes.RESPONSE_FAILED,
584 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
588 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog()
589 throws ExecutionException, InterruptedException {
590 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result =
591 new AddOpenroadmOperationalModesToCatalogImpl(catalogDataStoreOperations)
592 .invoke(CatalogDataUtils.buildAddORToCatalogInput());
594 ResponseCodes.RESPONSE_OK,
595 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
599 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog()
600 throws ExecutionException, InterruptedException {
601 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result =
602 new AddSpecificOperationalModesToCatalogImpl(catalogDataStoreOperations)
603 .invoke(CatalogDataUtils.buildAddSpecificToCatalogInput());
605 ResponseCodes.RESPONSE_OK,
606 result.get().getResult().getConfigurationResponseCommon().getResponseCode());