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.pce.service.PathComputationService;
34 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
35 import org.opendaylight.transportpce.servicehandler.ServiceInput;
36 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
37 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperationsImpl;
38 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
39 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
40 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
41 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
42 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
43 import org.opendaylight.transportpce.servicehandler.utils.CatalogDataUtils;
44 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
45 import org.opendaylight.transportpce.test.AbstractTest;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
81 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
82 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
84 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
86 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.ResourceBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPointBuilder;
88 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
89 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
90 import org.opendaylight.yangtools.yang.common.RpcResult;
91 import org.opendaylight.yangtools.yang.common.Uint32;
93 @ExtendWith(MockitoExtension.class)
94 public class ServicehandlerImplTest extends AbstractTest {
97 private PathComputationService pathComputationService;
99 private RendererServiceOperations rendererServiceOperations;
101 private NotificationPublishService notificationPublishService;
103 private PceListenerImpl pceListenerImpl;
105 private RendererListenerImpl rendererListenerImpl;
107 private NetworkModelListenerImpl networkModelListenerImpl;
109 private ServiceDataStoreOperations serviceDataStoreOperations;
110 private CatalogDataStoreOperations catalogDataStoreOperations;
111 private ServiceCreateInput serviceCreateInput;
112 private ServiceDeleteInput serviceDeleteInput;
113 private ServiceReconfigureInput serviceReconfigureInput;
114 private ServiceRestorationInput serviceRestorationInput;
115 private ServiceRerouteInput serviceRerouteInput;
116 private ListeningExecutorService executorService;
117 private CountDownLatch endSignal;
118 private static final int NUM_THREADS = 5;
122 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
123 endSignal = new CountDownLatch(1);
124 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
125 this.catalogDataStoreOperations = new CatalogDataStoreOperationsImpl(getNewDataBroker());
126 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
127 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
128 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
129 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
130 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
134 void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
135 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
136 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
137 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
138 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl
139 .serviceCreate(new ServiceCreateInputBuilder().build());
140 result.addListener(() -> endSignal.countDown(), executorService);
143 ResponseCodes.RESPONSE_FAILED,
144 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
148 void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException,
149 InterruptedException {
150 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
151 when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
152 .thenReturn(Optional.of(
153 new ServicesBuilder()
154 .setServiceName(serviceCreateInput.getServiceName())
156 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
157 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
158 networkModelListenerImpl, serviceDSOperations, catalogDataStoreOperations);
159 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
160 result.addListener(() -> endSignal.countDown(), executorService);
164 ResponseCodes.RESPONSE_FAILED,
165 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
169 void createServiceShouldBeSuccessfulWhenPerformPCESuccessful()
170 throws ExecutionException, InterruptedException {
171 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
172 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
173 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
174 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
175 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
176 result.addListener(() -> endSignal.countDown(), executorService);
180 ResponseCodes.RESPONSE_OK,
181 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
185 void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
186 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
187 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
188 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
189 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(
190 new ServiceDeleteInputBuilder()
191 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
195 result.addListener(() -> endSignal.countDown(), executorService);
199 ResponseCodes.RESPONSE_FAILED,
200 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
204 void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
205 ServicehandlerImpl servicehandlerImpl =
206 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
207 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
208 serviceDataStoreOperations, catalogDataStoreOperations);
209 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
210 result.addListener(() -> endSignal.countDown(), executorService);
214 ResponseCodes.RESPONSE_FAILED,
215 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
219 void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
220 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
221 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
222 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
223 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
224 serviceDataStoreOperations.createService(serviceCreateInput);
225 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
226 result.addListener(() -> endSignal.countDown(), executorService);
230 ResponseCodes.RESPONSE_OK,
231 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
236 void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
237 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
238 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
239 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
240 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
241 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
242 result.addListener(() -> endSignal.countDown(), executorService);
246 ResponseCodes.RESPONSE_FAILED,
247 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
251 void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
252 throws ExecutionException, InterruptedException {
253 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
254 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
255 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
256 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
257 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
258 servicehandlerImpl.serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
259 result.addListener(() -> endSignal.countDown(), executorService);
263 ResponseCodes.RESPONSE_OK,
264 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
268 void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
269 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
270 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
271 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
272 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
273 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
274 result.addListener(() -> endSignal.countDown(), executorService);
281 void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
282 //action -> service reconfigure
283 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
284 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
285 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
286 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
287 serviceReconfigureInput);
289 result.addListener(() -> endSignal.countDown(), executorService);
295 void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
296 // serviceReconfigure is calling service delete method in renderer
297 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
298 //create service to reconfigure
299 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
300 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
301 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
302 serviceDataStoreOperations.createService(serviceCreateInput);
304 //service reconfigure test action
305 //ServiceReconfigureInput is created with the same service information that is created before
306 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
307 serviceReconfigureInput);
308 result.addListener(() -> endSignal.countDown(), executorService);
314 void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
315 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
316 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
317 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
318 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl
319 .serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
320 result.addListener(() -> endSignal.countDown(), executorService);
327 void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
328 //action -> service restore
329 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
330 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
331 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
332 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
333 serviceRestorationInput);
335 result.addListener(() -> endSignal.countDown(), executorService);
341 void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
342 // serviceRestoration is calling service delete method in renderer
343 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
344 //create service to restore
345 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
346 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
347 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
348 serviceDataStoreOperations.createService(serviceCreateInput);
350 //service Restoration test action
351 //ServiceRestorationInput is created with the same service information that is created before
352 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
353 serviceRestorationInput);
354 result.addListener(() -> endSignal.countDown(), executorService);
360 void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
361 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
362 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
363 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
364 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
365 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
366 result.addListener(() -> endSignal.countDown(), executorService);
371 ResponseCodes.RESPONSE_FAILED,
372 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
376 void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
377 //action -> service reconfigure
378 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
379 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
380 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
381 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl
382 .serviceReroute(serviceRerouteInput);
384 result.addListener(() -> endSignal.countDown(), executorService);
389 ResponseCodes.RESPONSE_FAILED,
390 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
394 void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
395 when(pathComputationService.pathComputationRerouteRequest(any()))
396 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
397 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
398 .setResponseCode(ResponseCodes.RESPONSE_OK)
401 Map<AToZKey, AToZ> atoz = Map.of(
405 .setResource(new ResourceBuilder()
406 .setResource(new TerminationPointBuilder()
407 .setTpNodeId("tpNodeIdC")
410 .setState(State.InService)
416 .setResource(new ResourceBuilder()
417 .setResource(new TerminationPointBuilder()
418 .setTpNodeId("tpNodeIdD")
421 .setState(State.InService)
423 .build(), new AToZKey("2"),
426 .setResource(new ResourceBuilder()
427 .setResource(new TerminationPointBuilder()
428 .setTpNodeId("tpNodeIdA")
431 .setState(State.InService)
436 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
437 new PathComputationRequestOutputBuilder()
438 .setResponseParameters(new ResponseParametersBuilder()
439 .setPathDescription(new PathDescriptionBuilder()
440 .setAToZDirection(new AToZDirectionBuilder()
442 .setRate(Uint32.valueOf(1))
444 .setZToADirection(new ZToADirectionBuilder()
445 .setRate(Uint32.valueOf(1))
451 serviceDataStoreOperations.createService(serviceCreateInput);
452 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = new ServicehandlerImpl(getNewDataBroker(),
453 pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl,
454 rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations)
455 .serviceReroute(serviceRerouteInput);
456 result.addListener(() -> endSignal.countDown(), executorService);
461 ResponseCodes.RESPONSE_OK,
462 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
466 void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
467 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
468 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
469 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
470 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
471 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder().setCommonId("").build());
472 result.addListener(() -> endSignal.countDown(), executorService);
476 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
478 ResponseCodes.RESPONSE_FAILED,
479 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
481 LogMessages.SERVICE_NON_COMPLIANT,
482 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
486 void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
487 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
488 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
489 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
490 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(
491 ServiceDataUtils.buildTempServiceDeleteInput());
492 result.addListener(() -> endSignal.countDown(), executorService);
496 ResponseCodes.RESPONSE_FAILED,
497 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
501 void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
502 when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
504 //create temp service to delete in the temp delete action
505 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
506 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
507 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
508 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
509 serviceDataStoreOperations.createTempService(createInput);
511 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
512 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
513 result.addListener(() -> endSignal.countDown(), executorService);
517 ResponseCodes.RESPONSE_OK,
518 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
522 void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
523 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
524 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
525 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
526 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
527 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
528 result.addListener(() -> endSignal.countDown(), executorService);
532 ResponseCodes.RESPONSE_FAILED,
533 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
537 void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
538 throws ExecutionException, InterruptedException {
539 when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
541 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
542 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
543 networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
545 ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(
546 ServiceDataUtils.buildTempServiceCreateInput());
547 result.addListener(() -> endSignal.countDown(), executorService);
551 ResponseCodes.RESPONSE_OK,
552 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
556 public void addOpenroadmOperationalModesToCatalogShouldBeFailedWithEmptyInput() throws ExecutionException,
557 InterruptedException {
558 ServicehandlerImpl servicehandlerImpl =
559 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
560 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
561 serviceDataStoreOperations,catalogDataStoreOperations);
562 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result = servicehandlerImpl
563 .addOpenroadmOperationalModesToCatalog(new AddOpenroadmOperationalModesToCatalogInputBuilder().build());
564 RpcResult<AddOpenroadmOperationalModesToCatalogOutput> rpcResult = result.get();
566 ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon()
571 public void addSpecificOperationalModesToCatalogShouldBeFailedWithEmptyInput() throws ExecutionException,
572 InterruptedException {
573 ServicehandlerImpl servicehandlerImpl =
574 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
575 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
576 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 =
591 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
592 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
593 serviceDataStoreOperations,catalogDataStoreOperations);
594 ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>> result = servicehandlerImpl
595 .addOpenroadmOperationalModesToCatalog(input);
596 RpcResult<AddOpenroadmOperationalModesToCatalogOutput> rpcResult = result.get();
598 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
602 public void addSpecificOperationalModesToCatalogShouldBeSuccessfulWhenAddSpecificToCatalog() throws
603 ExecutionException, InterruptedException {
604 AddSpecificOperationalModesToCatalogInput input = CatalogDataUtils.buildAddSpecificToCatalogInput();
606 ServicehandlerImpl servicehandlerImpl =
607 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
608 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
609 serviceDataStoreOperations,catalogDataStoreOperations);
610 ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> result = servicehandlerImpl
611 .addSpecificOperationalModesToCatalog(input);
612 RpcResult<AddSpecificOperationalModesToCatalogOutput> rpcResult = result.get();
614 ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());