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.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.mock;
12 import static org.opendaylight.transportpce.servicehandler.impl.ServicehandlerImpl.LogMessages;
14 import com.google.common.util.concurrent.Futures;
15 import com.google.common.util.concurrent.ListenableFuture;
16 import com.google.common.util.concurrent.ListeningExecutorService;
17 import com.google.common.util.concurrent.MoreExecutors;
19 import java.util.Optional;
20 import java.util.concurrent.CountDownLatch;
21 import java.util.concurrent.ExecutionException;
22 import java.util.concurrent.Executors;
23 import org.junit.Assert;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.mockito.Mock;
27 import org.mockito.Mockito;
28 import org.mockito.MockitoAnnotations;
29 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
30 import org.opendaylight.transportpce.common.ResponseCodes;
31 import org.opendaylight.transportpce.pce.service.PathComputationService;
32 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
33 import org.opendaylight.transportpce.servicehandler.ServiceInput;
34 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
35 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
36 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
37 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
38 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
39 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
40 import org.opendaylight.transportpce.test.AbstractTest;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutputBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutputBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInputBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.ServicesBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirectionBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirectionBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZ;
73 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.atoz.direction.AToZKey;
75 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.ResourceBuilder;
76 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.pce.resource.resource.resource.TerminationPointBuilder;
77 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
79 import org.opendaylight.yangtools.yang.common.RpcResult;
80 import org.opendaylight.yangtools.yang.common.Uint32;
82 public class ServicehandlerImplTest extends AbstractTest {
85 private PathComputationService pathComputationService;
88 private RendererServiceOperations rendererServiceOperations;
91 private NotificationPublishService notificationPublishService;
94 private PceListenerImpl pceListenerImpl;
97 private RendererListenerImpl rendererListenerImpl;
100 private NetworkModelListenerImpl networkModelListenerImpl;
102 private ServiceDataStoreOperations serviceDataStoreOperations;
103 private ServiceCreateInput serviceCreateInput;
104 private ServiceDeleteInput serviceDeleteInput;
105 private ServiceReconfigureInput serviceReconfigureInput;
106 private ServiceRestorationInput serviceRestorationInput;
107 private ServiceRerouteInput serviceRerouteInput;
108 private ListeningExecutorService executorService;
109 private CountDownLatch endSignal;
110 private static final int NUM_THREADS = 5;
113 public void setUp() {
114 executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
115 endSignal = new CountDownLatch(1);
116 MockitoAnnotations.openMocks(this);
117 this.serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(getNewDataBroker());
118 serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
119 serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
120 serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
121 serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
122 serviceRerouteInput = ServiceDataUtils.buildServiceRerouteInput();
126 public void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
127 ServicehandlerImpl servicehandlerImpl =
128 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
129 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
130 serviceDataStoreOperations);
131 ListenableFuture<RpcResult<ServiceCreateOutput>> result =
132 servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
133 result.addListener(() -> endSignal.countDown(), executorService);
137 ResponseCodes.RESPONSE_FAILED,
138 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
142 public void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException,
143 InterruptedException {
144 final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
145 Mockito.when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
146 .thenReturn(Optional.of(
147 new ServicesBuilder()
148 .setServiceName(serviceCreateInput.getServiceName())
150 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
151 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
152 networkModelListenerImpl, serviceDSOperations);
153 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
154 result.addListener(() -> endSignal.countDown(), executorService);
157 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
158 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
162 public void createServiceShouldBeSuccessfulWhenPerformPCESuccessful()
163 throws ExecutionException, InterruptedException {
164 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
165 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
166 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
167 networkModelListenerImpl, serviceDataStoreOperations);
168 ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
169 result.addListener(() -> endSignal.countDown(), executorService);
173 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
177 public void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
178 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
179 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
180 networkModelListenerImpl, serviceDataStoreOperations);
181 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(
182 new ServiceDeleteInputBuilder()
183 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
187 result.addListener(() -> endSignal.countDown(), executorService);
191 ResponseCodes.RESPONSE_FAILED,
192 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
196 public void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
197 ServicehandlerImpl servicehandlerImpl =
198 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
199 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
200 serviceDataStoreOperations);
201 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
202 result.addListener(() -> endSignal.countDown(), executorService);
206 ResponseCodes.RESPONSE_FAILED,
207 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
211 public void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
212 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
213 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
214 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
215 networkModelListenerImpl, serviceDataStoreOperations);
216 serviceDataStoreOperations.createService(serviceCreateInput);
217 ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(serviceDeleteInput);
218 result.addListener(() -> endSignal.countDown(), executorService);
222 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
227 public void serviceFeasibilityCheckShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
228 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
229 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
230 networkModelListenerImpl, serviceDataStoreOperations);
231 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
232 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
233 result.addListener(() -> endSignal.countDown(), executorService);
236 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
237 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
241 public void serviceFeasibilityCheckShouldBeSuccessfulWhenPerformPCESuccessful()
242 throws ExecutionException, InterruptedException {
243 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
244 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
245 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
246 networkModelListenerImpl, serviceDataStoreOperations);
247 ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
248 servicehandlerImpl.serviceFeasibilityCheck(ServiceDataUtils.buildServiceFeasibilityCheckInput());
249 result.addListener(() -> endSignal.countDown(), executorService);
253 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
257 public void serviceReconfigureShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
258 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
259 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
260 networkModelListenerImpl, serviceDataStoreOperations);
261 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
262 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
263 result.addListener(() -> endSignal.countDown(), executorService);
270 public void serviceReconfigureShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
271 //action -> service reconfigure
272 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
273 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
274 networkModelListenerImpl, serviceDataStoreOperations);
275 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
276 serviceReconfigureInput);
278 result.addListener(() -> endSignal.countDown(), executorService);
284 public void serviceReconfigureShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
285 // serviceReconfigure is calling service delete method in renderer
286 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
287 //create service to reconfigure
288 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
289 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
290 networkModelListenerImpl, serviceDataStoreOperations);
291 serviceDataStoreOperations.createService(serviceCreateInput);
293 //service reconfigure test action
294 //ServiceReconfigureInput is created with the same service information that is created before
295 ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(
296 serviceReconfigureInput);
297 result.addListener(() -> endSignal.countDown(), executorService);
303 public void serviceReRestorationShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
304 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
305 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
306 networkModelListenerImpl, serviceDataStoreOperations);
307 ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
308 servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
309 result.addListener(() -> endSignal.countDown(), executorService);
316 public void serviceRestorationShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
317 //action -> service restore
318 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
319 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
320 networkModelListenerImpl, serviceDataStoreOperations);
321 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
322 serviceRestorationInput);
324 result.addListener(() -> endSignal.countDown(), executorService);
330 public void serviceRestorationShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
331 // serviceRestoration is calling service delete method in renderer
332 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
333 //create service to restore
334 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
335 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
336 networkModelListenerImpl, serviceDataStoreOperations);
337 serviceDataStoreOperations.createService(serviceCreateInput);
339 //service Restoration test action
340 //ServiceRestorationInput is created with the same service information that is created before
341 ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(
342 serviceRestorationInput);
343 result.addListener(() -> endSignal.countDown(), executorService);
349 public void serviceRerouteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
350 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
351 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
352 networkModelListenerImpl, serviceDataStoreOperations);
353 ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
354 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
355 result.addListener(() -> endSignal.countDown(), executorService);
359 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
360 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
364 public void serviceRerouteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
365 //action -> service reconfigure
366 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
367 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
368 networkModelListenerImpl, serviceDataStoreOperations);
369 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(
370 serviceRerouteInput);
372 result.addListener(() -> endSignal.countDown(), executorService);
376 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
377 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
381 public void serviceRerouteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
382 Mockito.when(pathComputationService.pathComputationRerouteRequest(any()))
383 .thenReturn(Futures.immediateFuture(new PathComputationRerouteRequestOutputBuilder()
384 .setConfigurationResponseCommon(new ConfigurationResponseCommonBuilder()
385 .setResponseCode(ResponseCodes.RESPONSE_OK)
388 Map<AToZKey, AToZ> atoz = Map.of(
392 .setResource(new ResourceBuilder()
393 .setResource(new TerminationPointBuilder()
394 .setTpNodeId("tpNodeIdC")
397 .setState(State.InService)
403 .setResource(new ResourceBuilder()
404 .setResource(new TerminationPointBuilder()
405 .setTpNodeId("tpNodeIdD")
408 .setState(State.InService)
410 .build(), new AToZKey("2"),
413 .setResource(new ResourceBuilder()
414 .setResource(new TerminationPointBuilder()
415 .setTpNodeId("tpNodeIdA")
418 .setState(State.InService)
423 serviceDataStoreOperations.createServicePath(new ServiceInput(serviceCreateInput),
424 new PathComputationRequestOutputBuilder()
425 .setResponseParameters(new ResponseParametersBuilder()
426 .setPathDescription(new PathDescriptionBuilder()
427 .setAToZDirection(new AToZDirectionBuilder()
429 .setRate(Uint32.valueOf(1))
431 .setZToADirection(new ZToADirectionBuilder()
432 .setRate(Uint32.valueOf(1))
438 serviceDataStoreOperations.createService(serviceCreateInput);
439 ListenableFuture<RpcResult<ServiceRerouteOutput>> result = new ServicehandlerImpl(getNewDataBroker(),
440 pathComputationService, rendererServiceOperations, notificationPublishService, pceListenerImpl,
441 rendererListenerImpl, networkModelListenerImpl, serviceDataStoreOperations)
442 .serviceReroute(serviceRerouteInput);
443 result.addListener(() -> endSignal.countDown(), executorService);
448 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
452 public void tempServiceDeleteShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
453 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
454 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
455 networkModelListenerImpl, serviceDataStoreOperations);
456 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
457 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder().setCommonId("").build());
458 result.addListener(() -> endSignal.countDown(), executorService);
462 RpcResult<TempServiceDeleteOutput> rpcResult = result.get();
464 ResponseCodes.RESPONSE_FAILED,
465 rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
467 LogMessages.SERVICE_NON_COMPLIANT,
468 rpcResult.getResult().getConfigurationResponseCommon().getResponseMessage());
472 public void tempServiceDeleteShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
473 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
474 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
475 networkModelListenerImpl, serviceDataStoreOperations);
476 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(
477 ServiceDataUtils.buildTempServiceDeleteInput());
478 result.addListener(() -> endSignal.countDown(), executorService);
481 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
482 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
486 public void tempServiceDeleteShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
487 Mockito.when(rendererServiceOperations.serviceDelete(any(), any())).thenReturn(Futures.immediateFuture(any()));
489 //create temp service to delete in the temp delete action
490 ServicehandlerImpl servicehandlerImpl =
491 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
492 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
493 serviceDataStoreOperations);
494 TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
495 serviceDataStoreOperations.createTempService(createInput);
497 TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(createInput.getCommonId());
498 ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
499 result.addListener(() -> endSignal.countDown(), executorService);
503 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());
507 public void tempServiceCreateShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
508 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
509 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
510 networkModelListenerImpl, serviceDataStoreOperations);
511 ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
512 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
513 result.addListener(() -> endSignal.countDown(), executorService);
516 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
517 result.get().getResult().getConfigurationResponseCommon().getResponseCode());
522 public void tempServiceCreateShouldBeSuccessfulWhenPerformPCESuccessful()
523 throws ExecutionException, InterruptedException {
524 Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
526 ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
527 rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
528 networkModelListenerImpl, serviceDataStoreOperations);
530 ListenableFuture<RpcResult<TempServiceCreateOutput>> result = servicehandlerImpl.tempServiceCreate(
531 ServiceDataUtils.buildTempServiceCreateInput());
532 result.addListener(() -> endSignal.countDown(), executorService);
536 ResponseCodes.RESPONSE_OK, result.get().getResult().getConfigurationResponseCommon().getResponseCode());