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.when;
14 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
16 import com.google.common.util.concurrent.Futures;
17 import com.google.common.util.concurrent.ListenableFuture;
18 import com.google.common.util.concurrent.ListeningExecutorService;
19 import com.google.common.util.concurrent.MoreExecutors;
21 import java.util.Optional;
22 import java.util.concurrent.CountDownLatch;
23 import java.util.concurrent.ExecutionException;
24 import java.util.concurrent.Executors;
25 import org.junit.Assert;
26 import org.junit.jupiter.api.BeforeEach;
27 import org.junit.jupiter.api.Test;
28 import org.junit.jupiter.api.extension.ExtendWith;
29 import org.mockito.Mock;
30 import org.mockito.junit.jupiter.MockitoExtension;
31 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
32 import org.opendaylight.transportpce.common.ResponseCodes;
33 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
34 import org.opendaylight.transportpce.pce.service.PathComputationService;
35 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
36 import org.opendaylight.transportpce.servicehandler.ServiceInput;
37 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
38 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
39 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
40 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
41 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
42 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
43 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
44 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
45 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
46 import org.opendaylight.transportpce.test.AbstractTest;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInputBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
82 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
84 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
85 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZBuilder;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.ResourceBuilder;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPointBuilder;
89 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
90 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
91 import org.opendaylight.yangtools.yang.common.RpcResult;
92 import org.opendaylight.yangtools.yang.common.Uint32;
94 @ExtendWith(MockitoExtension.class)
95 public class ServicehandlerImplTest extends AbstractTest {
98 private PathComputationService pathComputationService;
100 private RendererServiceOperations rendererServiceOperations;
102 private NotificationPublishService notificationPublishService;
104 private PceListener pceListenerImpl;
106 private RendererListener rendererListenerImpl;
108 private NetworkListener networkModelListenerImpl;
110 private ServiceDataStoreOperations serviceDataStoreOperations;
111 private CatalogDataStoreOperations catalogDataStoreOperations;
112 private ServiceCreateInput serviceCreateInput;
113 private ServiceDeleteInput serviceDeleteInput;
114 private ServiceReconfigureInput serviceReconfigureInput;
115 private ServiceRestorationInput serviceRestorationInput;
116 private ServiceRerouteInput serviceRerouteInput;
117 private ListeningExecutorService executorService;
118 private CountDownLatch endSignal;
119 private static final int NUM_THREADS = 5;
123 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
124 endSignal = new CountDownLatch(1);
125 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
126 this.catalogDataStoreOperations = new CatalogDataStoreOperationsImpl(
127 new NetworkTransactionImpl(getDataBroker()));
128 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
129 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
130 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
131 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
132 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
136 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
137 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
138 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
139 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
140 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl
141 .serviceCreate(new ServiceCreateInputBuilder().build());
142 result.addListener(() -> endSignal.countDown(), executorService);
145 ResponseCodes.RESPONSE_FAILED,
146 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
150 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException,
151 InterruptedException {
152 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
153 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
154 .thenReturn(Optional.of(
155 new ServicesBuilder()
156 .setServiceName(serviceCreateInput.getServiceName())
158 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
159 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
160 networkModelListenerImpl, serviceDSOperations, catalogDataStoreOperations);
161 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
162 result.addListener(() -> endSignal.countDown(), executorService);
166 ResponseCodes.RESPONSE_FAILED,
167 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
171 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful()
172 throws ExecutionException, InterruptedException {
173 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
174 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
175 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
176 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
177 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
178 result.addListener(() -> endSignal.countDown(), executorService);
182 ResponseCodes.RESPONSE_OK,
183 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
187 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
188 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
189 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
190 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
191 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(
192 new ServiceDeleteInputBuilder()
193 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
197 result.addListener(() -> endSignal.countDown(), executorService);
201 ResponseCodes.RESPONSE_FAILED,
202 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
206 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
207 ServicehandlerImpl servicehandlerImpl =
208 new ServicehandlerImpl(pathComputationService, rendererServiceOperations,
209 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
210 serviceDataStoreOperations, catalogDataStoreOperations);
211 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
212 result.addListener(() -> endSignal.countDown(), executorService);
216 ResponseCodes.RESPONSE_FAILED,
217 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
221 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
222 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
223 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
224 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
225 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
226 serviceDataStoreOperations.createService(serviceCreateInput);
227 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
228 result.addListener(() -> endSignal.countDown(), executorService);
232 ResponseCodes.RESPONSE_OK,
233 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
238 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
239 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
240 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
241 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
242 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
243 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
244 result.addListener(() -> endSignal.countDown(), executorService);
248 ResponseCodes.RESPONSE_FAILED,
249 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
253 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
254 throws ExecutionException, InterruptedException {
255 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
256 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
257 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
258 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
259 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
260 servicehandlerImpl.serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
261 result.addListener(() -> endSignal.countDown(), executorService);
265 ResponseCodes.RESPONSE_OK,
266 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
270 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
271 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
272 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
273 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
274 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
275 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
276 result.addListener(() -> endSignal.countDown(), executorService);
283 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
284 //action -> service reconfigure
285 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
286 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
287 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
288 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
289 serviceReconfigureInput);
291 result.addListener(() -> endSignal.countDown(), executorService);
297 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
298 // serviceReconfigure is calling service delete method in renderer
299 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
300 //create service to reconfigure
301 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
302 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
303 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
304 serviceDataStoreOperations.createService(serviceCreateInput);
306 //service reconfigure test action
307 //ServiceReconfigureInput is created with the same service information that is created before
308 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
309 serviceReconfigureInput);
310 result.addListener(() -> endSignal.countDown(), executorService);
316 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
317 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
318 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
319 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
320 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl
321 .serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
322 result.addListener(() -> endSignal.countDown(), executorService);
329 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
330 //action -> service restore
331 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
332 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
333 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
334 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
335 serviceRestorationInput);
337 result.addListener(() -> endSignal.countDown(), executorService);
343 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
344 // serviceRestoration is calling service delete method in renderer
345 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
346 //create service to restore
347 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
348 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
349 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
350 serviceDataStoreOperations.createService(serviceCreateInput);
352 //service Restoration test action
353 //ServiceRestorationInput is created with the same service information that is created before
354 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
355 serviceRestorationInput);
356 result.addListener(() -> endSignal.countDown(), executorService);
362 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
363 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
364 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
365 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
366 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
367 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
368 result.addListener(() -> endSignal.countDown(), executorService);
373 ResponseCodes.RESPONSE_FAILED,
374 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
378 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
379 //action -> service reconfigure
380 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
381 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
382 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
383 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl
384 .serviceReroute(serviceRerouteInput);
386 result.addListener(() -> endSignal.countDown(), executorService);
391 ResponseCodes.RESPONSE_FAILED,
392 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
396 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
397 when(pathComputationService.pathComputationRerouteRequest(any()))
398 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
399 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
400 .setResponseCode(ResponseCodes.RESPONSE_OK)
403 Map<AToZKey, AToZ> atoz = Map.of(
407 .setResource(new ResourceBuilder()
408 .setResource(new TerminationPointBuilder()
409 .setTpNodeId("tpNodeIdC")
412 .setState(State.InService)
418 .setResource(new ResourceBuilder()
419 .setResource(new TerminationPointBuilder()
420 .setTpNodeId("tpNodeIdD")
423 .setState(State.InService)
425 .build(), new AToZKey("2"),
428 .setResource(new ResourceBuilder()
429 .setResource(new TerminationPointBuilder()
430 .setTpNodeId("tpNodeIdA")
433 .setState(State.InService)
438 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
439 new PathComputationRequestOutputBuilder()
440 .setResponseParameters(new ResponseParametersBuilder()
441 .setPathDescription(new PathDescriptionBuilder()
442 .setAToZDirection(new AToZDirectionBuilder()
444 .setRate(Uint32.valueOf(1))
446 .setZToADirection(new ZToADirectionBuilder()
447 .setRate(Uint32.valueOf(1))
453 serviceDataStoreOperations.createService(serviceCreateInput);
454 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = new ServicehandlerImpl(pathComputationService,
455 rendererServiceOperations, notificationPublishService, pceListenerImpl,
456 rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations)
457 .serviceReroute(serviceRerouteInput);
458 result.addListener(() -> endSignal.countDown(), executorService);
463 ResponseCodes.RESPONSE_OK,
464 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
468 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
469 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
470 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
471 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
472 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
473 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder().setCommonId("").build());
474 result.addListener(() -> endSignal.countDown(), executorService);
478 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
480 ResponseCodes.RESPONSE_FAILED,
481 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
483 LogMessages.SERVICE_NON_COMPLIANT,
484 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
488 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
489 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
490 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
491 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
492 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(
493 ServiceDataUtils.buildTempServiceDeleteInput());
494 result.addListener(() -> endSignal.countDown(), executorService);
498 ResponseCodes.RESPONSE_FAILED,
499 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
503 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
504 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
506 //create temp service to delete in the temp delete action
507 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
508 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
509 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
510 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
511 serviceDataStoreOperations.createTempService(createInput);
513 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
514 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
515 result.addListener(() -> endSignal.countDown(), executorService);
519 ResponseCodes.RESPONSE_OK,
520 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
524 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
525 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
526 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
527 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
528 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
529 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
530 result.addListener(() -> endSignal.countDown(), executorService);
534 ResponseCodes.RESPONSE_FAILED,
535 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
539 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
540 throws ExecutionException, InterruptedException {
541 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
543 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
544 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
545 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
547 ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(
548 ServiceDataUtils.buildTempServiceCreateInput());
549 result.addListener(() -> endSignal.countDown(), executorService);
553 ResponseCodes.RESPONSE_OK,
554 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
558 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput() throws ExecutionException,
559 InterruptedException {
560 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
561 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
562 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
563 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result = servicehandlerImpl
564 .addOpenroadmOperationalModesToCatalog(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
565 RpcResult<AddOpenroadmOperationalModesToCatalogOutput> rpcResult = result.get();
567 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon()
572 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput() throws ExecutionException,
573 InterruptedException {
574 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
575 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
576 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
577 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result = servicehandlerImpl
578 .addSpecificOperationalModesToCatalog(new AddSpecificOperationalModesToCatalogInputBuilder().build());
579 RpcResult<AddSpecificOperationalModesToCatalogOutput> rpcResult = result.get();
581 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon()
586 public void addOpenroadmOperationalModesToCatalogShouldBeSuccessfulWhenAddORToCatalog() throws ExecutionException,
587 InterruptedException {
588 AddOpenroadmOperationalModesToCatalogInput input = CatalogDataUtils.buildAddORToCatalogInput();
590 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
591 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
592 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
593 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result = servicehandlerImpl
594 .addOpenroadmOperationalModesToCatalog(input);
595 RpcResult<AddOpenroadmOperationalModesToCatalogOutput> rpcResult = result.get();
597 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
601 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog() throws
602 ExecutionException, InterruptedException {
603 AddSpecificOperationalModesToCatalogInput input = CatalogDataUtils.buildAddSpecificToCatalogInput();
605 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(pathComputationService,
606 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
607 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
608 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result = servicehandlerImpl
609 .addSpecificOperationalModesToCatalog(input);
610 RpcResult<AddSpecificOperationalModesToCatalogOutput> rpcResult = result.get();
612 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());