2 * Copyright © 2018 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;
12 import com.google.common.util.concurrent.ListeningExecutorService;
13 import com.google.common.util.concurrent.MoreExecutors;
15 import java.lang.reflect.InvocationTargetException;
16 import java.lang.reflect.Method;
17 import java.util.Arrays;
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Optional;
21 import java.util.concurrent.ExecutionException;
22 import java.util.concurrent.Executors;
23 import java.util.concurrent.Future;
25 import org.junit.Assert;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.InjectMocks;
29 import org.mockito.Mock;
30 import org.mockito.Mockito;
31 import org.mockito.MockitoAnnotations;
32 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
33 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
34 import org.opendaylight.transportpce.common.ResponseCodes;
35 import org.opendaylight.transportpce.pce.service.PathComputationService;
36 import org.opendaylight.transportpce.pce.utils.PceTestData;
37 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
38 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
39 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
40 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
41 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
42 import org.opendaylight.transportpce.servicehandler.ServiceInput;
43 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
44 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
45 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
46 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
47 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
48 import org.opendaylight.transportpce.servicehandler.stub.StubPceServiceOperations;
49 import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
50 import org.opendaylight.transportpce.servicehandler.utils.MockedNotificationServiceWrapper;
51 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
52 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
53 import org.opendaylight.transportpce.test.AbstractTest;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutputBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.TransportpcePceListener;
57 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.TransportpceRendererListener;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceNotificationTypes;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirectionBuilder;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirectionBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.Lgx;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
87 import org.opendaylight.yangtools.concepts.ListenerRegistration;
88 import org.opendaylight.yangtools.yang.common.RpcResult;
89 import org.slf4j.Logger;
90 import org.slf4j.LoggerFactory;
92 public class ServiceHandlerImplTest extends AbstractTest {
94 private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerImplTest.class);
95 private static final int NUMBER_OF_THREADS = 4;
97 private PathComputationService pathComputationService;
98 private RendererServiceOperations rendererServiceOperations;
99 private ServicehandlerImpl serviceHandler;
100 private PceListenerImpl pceListenerImpl;
101 private RendererListenerImpl rendererListenerImpl;
102 private ListeningExecutorService executor;
103 private NotificationPublishService notificationPublishService;
104 private NotificationService notificationService;
105 private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
106 private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
107 private MockedNotificationServiceWrapper mockedNotificationServiceWrapper;
110 private ServiceDataStoreOperations serviceDataStoreOperationsMock;
112 private PCEServiceWrapper pceServiceWrapperMock;
114 private RendererServiceWrapper rendererServiceWrapperMock;
116 private PathComputationService pathComputationServiceMock;
118 private RendererServiceOperations rendererServiceOperationsMock;
120 private ComplianceCheckResult complianceCheckResultMock;
122 private Optional<Services> servicesOptionalMock;
124 private PceListenerImpl pceListenerImplMock;
126 private RendererListenerImpl rendererListenerImplMock;
128 private NotificationPublishService notificationPublishServiceMock;
130 private NetworkModelWavelengthService networkModelWavelengthServiceMock;
132 private ServicehandlerImpl serviceHandlerImplMock;
135 public void setUp() {
136 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
137 this.rendererServiceOperations, this.notificationPublishService, this.pceListenerImpl,
138 this.rendererListenerImpl, this.networkModelWavelengthServiceMock);
139 this.serviceHandlerImplMock =
140 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, this.rendererServiceOperations,
141 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
142 MockitoAnnotations.initMocks(this);
145 public ServiceHandlerImplTest() throws Exception {
146 this.mockedNotificationServiceWrapper = new MockedNotificationServiceWrapper(getNotificationPublishService());
147 this.notificationPublishService = this.mockedNotificationServiceWrapper.getMockedNotificationService();
148 this.notificationService = getNotificationService();
149 this.pathComputationService = new StubPceServiceOperations(notificationPublishService);
150 this.rendererServiceOperations = new StubRendererServiceOperations(this.networkModelWavelengthServiceMock,
151 getDataBroker(), notificationPublishService);
152 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
153 "topologyData/NW-simple-topology.xml");
154 this.pceListenerImpl =
155 new PceListenerImpl(rendererServiceOperations, pathComputationService, notificationPublishService,
157 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
158 this.pceListenerImpl.setServiceReconfigure(false);
159 this.rendererListenerImpl =
160 new RendererListenerImpl(pathComputationServiceMock, notificationPublishService);
161 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
162 this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
163 pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
164 rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
170 public void testCreateServiceValid() throws ExecutionException, InterruptedException {
171 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
172 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
173 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
174 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
175 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
176 PceTestData.getPCE_simpletopology_test1_result((long) 5))
177 .setConfigurationResponseCommon(configurationResponseCommon).build();
178 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
179 .thenReturn(pathComputationRequestOutput);
180 Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
181 Assert.assertNotNull(output0);
182 Assert.assertTrue(output0.get().isSuccessful());
183 Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
184 ResponseCodes.FINAL_ACK_NO,"PCE calculation in progress", ResponseCodes.RESPONSE_OK)
186 Assert.assertEquals(0, output0.get().getErrors().size());
190 public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
191 ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
192 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyServiceNameInput);
193 emptyServiceNameInput = builtInput.setServiceName("").build();
194 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
195 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
196 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
201 public void createServiceHandlerInvalidIfNameIsNull() throws ExecutionException, InterruptedException {
202 ServiceCreateInput nullServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
203 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(nullServiceNameInput);
204 nullServiceNameInput = builtInput.setServiceName(null).build();
205 Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
206 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
207 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
212 public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
213 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
214 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
215 emptyServiceNameInput = builtInput.setCommonId("").build();
216 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
217 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
218 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
223 public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
224 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
225 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
226 emptyServiceNameInput = builtInput.setCommonId(null).build();
227 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
228 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
229 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
234 public void createServiceHnadlerInvalidIfConTypeIsEmpty() throws ExecutionException, InterruptedException {
235 ServiceCreateInput emptyConTypeInput = ServiceDataUtils.buildServiceCreateInput();
236 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyConTypeInput);
237 emptyConTypeInput = builtInput.setConnectionType(null).build();
238 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyConTypeInput).get().getResult(),
239 ModelMappingUtils.createCreateServiceReply(emptyConTypeInput, ResponseCodes.FINAL_ACK_YES,
240 "Service ConnectionType is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
244 public void createServiceHandlerInvalidIfSdncRequestHeaderNull() throws ExecutionException, InterruptedException {
245 ServiceCreateInput emptySdncRequestHeader = ServiceDataUtils.buildServiceCreateInput();
246 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptySdncRequestHeader);
247 emptySdncRequestHeader = buildInput.setSdncRequestHeader(null).build();
248 ServiceCreateOutput result = this.serviceHandler.serviceCreate(emptySdncRequestHeader).get().getResult();
249 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
250 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
251 ResponseCodes.FINAL_ACK_YES);
255 public void createServiceHandlerInvalidIfRequestIdEmpty() throws ExecutionException, InterruptedException {
256 ServiceCreateInput emptyRequestId = ServiceDataUtils.buildServiceCreateInput();
257 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyRequestId);
258 emptyRequestId = buildInput
259 .setSdncRequestHeader(
260 new SdncRequestHeaderBuilder(emptyRequestId.getSdncRequestHeader()).setRequestId("").build())
262 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyRequestId).get().getResult(),
264 .createCreateServiceReply(emptyRequestId, ResponseCodes.FINAL_ACK_YES,
265 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
270 public void createServiceHandlerInvalidIfRequestIdNull() throws ExecutionException, InterruptedException {
271 ServiceCreateInput nullRequestId = ServiceDataUtils.buildServiceCreateInput();
272 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(nullRequestId);
273 nullRequestId = buildInput
274 .setSdncRequestHeader(
275 new SdncRequestHeaderBuilder(nullRequestId.getSdncRequestHeader()).setRequestId(null).build())
277 Assert.assertEquals(this.serviceHandler.serviceCreate(nullRequestId).get().getResult(),
279 .createCreateServiceReply(nullRequestId, ResponseCodes.FINAL_ACK_YES,
280 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
285 public void serviceHandlerInvalidServiceActionIsNull() throws ExecutionException, InterruptedException {
286 ServiceCreateInput emptyServiceAction = ServiceDataUtils.buildServiceCreateInput();
287 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyServiceAction);
288 emptyServiceAction = buildInput.setSdncRequestHeader(
289 new SdncRequestHeaderBuilder(emptyServiceAction.getSdncRequestHeader()).setRpcAction(null).build())
291 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceAction).get().getResult(),
293 .createCreateServiceReply(emptyServiceAction, ResponseCodes.FINAL_ACK_YES,
294 "Service sndc-request-header 'rpc-action' is not set ", ResponseCodes.RESPONSE_FAILED)
299 public void serviceHandlerInvalidServiceActionIsNotCreate() throws ExecutionException, InterruptedException {
300 ServiceCreateInput notCreateServiceAction = ServiceDataUtils.buildServiceCreateInput();
301 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notCreateServiceAction);
302 notCreateServiceAction = buildInput
303 .setSdncRequestHeader(new SdncRequestHeaderBuilder(notCreateServiceAction.getSdncRequestHeader())
304 .setRpcAction(RpcActions.ServiceFeasibilityCheck).build())
306 Assert.assertEquals(this.serviceHandler.serviceCreate(notCreateServiceAction).get().getResult(),
307 ModelMappingUtils.createCreateServiceReply(notCreateServiceAction, ResponseCodes.FINAL_ACK_YES,
308 "Service sdncRequestHeader rpc-action '"
309 + notCreateServiceAction.getSdncRequestHeader().getRpcAction() + "' not equal to '"
310 + RpcActions.ServiceCreate.name() + "'",
311 ResponseCodes.RESPONSE_FAILED).get().getResult());
315 public void createServiceHandlerNotValidServiceAEndIsNull() throws ExecutionException, InterruptedException {
316 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
317 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
318 notValidServiceAEnd = buildInput.setServiceAEnd(null).build();
319 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
320 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
321 "SERVICEAEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
325 public void createServiceHandlerNotValidServiceZEndIsNull() throws ExecutionException, InterruptedException {
326 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
327 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
328 notValidServiceAEnd = buildInput.setServiceZEnd(null).build();
329 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
330 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
331 "SERVICEZEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
335 public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
336 ServicehandlerImpl servicehandler =
337 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
338 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
339 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
340 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
342 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceAEnd).get().getResult(),
343 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
344 "Service " + ServiceEndpointType.SERVICEAEND + " rate is not set",
345 ResponseCodes.RESPONSE_FAILED).get().getResult());
349 public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
350 ServicehandlerImpl servicehandler =
351 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
352 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
353 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
354 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
356 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceZEnd).get().getResult(),
357 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
358 "Service " + ServiceEndpointType.SERVICEZEND + " rate is not set",
359 ResponseCodes.RESPONSE_FAILED).get().getResult());
363 public void createServiceHandlerNotValidServiceAEndClliIsNull()
364 throws ExecutionException, InterruptedException {
365 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
366 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
367 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setClli(null)
369 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
370 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
371 "Service" + ServiceEndpointType.SERVICEAEND + " clli format is not set",
372 ResponseCodes.RESPONSE_FAILED).get().getResult());
376 public void createServiceHandlerNotValidServiceZEndClliIsNull()
377 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
378 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
379 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
380 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setClli(null).build())
382 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceZEnd).get().getResult(),
383 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
384 "Service" + ServiceEndpointType.SERVICEZEND + " clli format is not set",
385 ResponseCodes.RESPONSE_FAILED).get().getResult());
389 public void createServiceHandlerNotValidServiceAEndAttributes()
390 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
391 HashMap<String, Object> notValidData = new HashMap<>();
392 notValidData.put("setServiceRate", 0L);
393 notValidData.put("setServiceFormat", null);
394 notValidData.put("setClli", "");
395 notValidData.put("setTxDirection", null);
396 notValidData.put("setRxDirection", null);
397 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
398 .ServiceAEndBuilder.class.getDeclaredMethods()) {
399 if (notValidData.containsKey(method.getName())) {
400 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
401 .buildServiceCreateInput());
402 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
403 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
404 method.invoke(serviceAEndBuilder, notValidData.get(method.getName()));
405 ServiceCreateOutput result = this.serviceHandler
406 .serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get().getResult();
407 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
408 ResponseCodes.FINAL_ACK_YES);
409 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
410 ResponseCodes.RESPONSE_FAILED);
416 public void createServiceHandlerNotValidServiceZEndAttributes()
417 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
418 HashMap<String, Object> notValidData = new HashMap<>();
419 notValidData.put("setServiceRate", 0L);
420 notValidData.put("setServiceFormat", null);
421 notValidData.put("setClli", "");
422 notValidData.put("setTxDirection", null);
423 notValidData.put("setRxDirection", null);
424 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
425 .ServiceZEndBuilder.class.getDeclaredMethods()) {
426 if (notValidData.containsKey(method.getName())) {
427 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
428 .buildServiceCreateInput());
429 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
430 .ServiceZEndBuilder serviceZEndBuilder = ServiceDataUtils.getServiceZEndBuild();
431 method.invoke(serviceZEndBuilder, notValidData.get(method.getName()));
432 ServiceCreateOutput result = this.serviceHandler
433 .serviceCreate(buildInput.setServiceZEnd(serviceZEndBuilder.build()).build()).get().getResult();
434 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
435 ResponseCodes.FINAL_ACK_YES);
436 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
437 ResponseCodes.RESPONSE_FAILED);
443 public void createServiceHandlerNotValidTxDirectionPort()
444 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
445 List<String> invalidData = Arrays.asList(null, "");
446 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
447 for (Method method : PortBuilder.class.getMethods()) {
448 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
449 for (Object data : invalidData) {
450 PortBuilder portBuilder = new PortBuilder(
451 serviceCreateInput.getServiceAEnd().getTxDirection().getPort());
452 method.invoke(portBuilder, data);
453 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(portBuilder.build(),
454 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
455 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
456 ResponseCodes.FINAL_ACK_YES);
457 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
458 ResponseCodes.RESPONSE_FAILED);
465 public void createServiceHandlerTxDirectionPortIsNull() throws ExecutionException, InterruptedException {
466 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(null,
467 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getLgx());
468 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
469 ResponseCodes.FINAL_ACK_YES);
470 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
474 public void createServiceHandlerNotValidTxDirectionLgx()
475 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
476 List<String> invalidData = Arrays.asList(null, "");
477 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
478 for (Method method : LgxBuilder.class.getMethods()) {
479 if (method.getName().startsWith("set")) {
480 for (Object data : invalidData) {
481 LgxBuilder lgxBuilder = new LgxBuilder(
482 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
483 method.invoke(lgxBuilder, data);
484 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
485 serviceCreateInput.getServiceAEnd().getTxDirection().getPort(), lgxBuilder.build());
486 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
487 ResponseCodes.FINAL_ACK_YES);
488 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
489 ResponseCodes.RESPONSE_FAILED);
496 public void createServiceHandlerTxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
497 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
498 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getPort(), null);
499 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
500 ResponseCodes.FINAL_ACK_YES);
501 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
504 private ServiceCreateOutput getTxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
505 throws InterruptedException, ExecutionException {
506 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
507 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
508 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
509 TxDirectionBuilder txDirectionBuilder = new TxDirectionBuilder(
510 serviceCreateInput.getServiceAEnd().getTxDirection());
511 txDirectionBuilder.setPort(port);
512 txDirectionBuilder.setLgx(lgx);
513 serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
514 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
515 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
517 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
522 public void createServiceHandlerNotValidRxDirectionPort()
523 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
524 List<String> invalidData = Arrays.asList(null, "");
525 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
526 for (Method method : PortBuilder.class.getMethods()) {
527 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
528 for (Object data : invalidData) {
529 PortBuilder portBuilder = new PortBuilder(
530 serviceCreateInput.getServiceAEnd().getRxDirection().getPort());
531 method.invoke(portBuilder, data);
532 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(portBuilder.build(),
533 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
534 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
535 ResponseCodes.FINAL_ACK_YES);
536 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
537 ResponseCodes.RESPONSE_FAILED);
544 public void createServiceHandlerRxDirectionPortIsNull()
545 throws ExecutionException, InterruptedException {
546 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(null,
547 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getLgx());
548 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
549 ResponseCodes.FINAL_ACK_YES);
550 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
554 public void createServiceHandlerNotValidRxDirectionLgx()
555 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
556 List<String> invalidData = Arrays.asList(null, "");
557 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
558 for (Method method : LgxBuilder.class.getMethods()) {
559 if (method.getName().startsWith("set")) {
560 for (Object data : invalidData) {
561 LgxBuilder lgxBuilder = new LgxBuilder(
562 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
563 method.invoke(lgxBuilder, data);
564 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
565 serviceCreateInput.getServiceAEnd().getRxDirection().getPort(), lgxBuilder.build());
566 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
567 ResponseCodes.FINAL_ACK_YES);
568 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
569 ResponseCodes.RESPONSE_FAILED);
576 public void createServiceHandlerRxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
577 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
578 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getPort(), null);
579 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
580 ResponseCodes.FINAL_ACK_YES);
581 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
585 public void createServiceHandlerResponseCodesNotPassed() throws ExecutionException, InterruptedException {
586 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
587 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
588 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
589 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("PCE calculation failed").build();
590 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
591 PceTestData.getPCE_simpletopology_test1_result((long) 5))
592 .setConfigurationResponseCommon(configurationResponseCommon).build();
593 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
594 .thenReturn(pathComputationRequestOutput);
595 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
596 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
599 private ServiceCreateOutput getRxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
600 throws InterruptedException, ExecutionException {
601 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
602 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
603 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
604 RxDirectionBuilder rxDirectionBuilder = new RxDirectionBuilder(
605 serviceCreateInput.getServiceAEnd().getRxDirection());
606 rxDirectionBuilder.setPort(port);
607 rxDirectionBuilder.setLgx(lgx);
608 serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
609 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
610 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
612 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
617 public void deleteServiceInvalidIfServiceNameIsEmpty() throws ExecutionException, InterruptedException {
619 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
620 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
621 serviceDeleteInput = builder
622 .setServiceDeleteReqInfo(
623 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName("").build())
625 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
626 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
627 ResponseCodes.FINAL_ACK_YES);
628 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
632 public void deleteServiceInvalidIfServiceNameIsNull() throws ExecutionException, InterruptedException {
634 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
635 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
636 serviceDeleteInput = builder
637 .setServiceDeleteReqInfo(
638 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName(null).build())
640 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
641 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
642 ResponseCodes.FINAL_ACK_YES);
643 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
647 public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
648 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
649 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
650 serviceDeleteInput = builder.setCommonId("").build();
651 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
652 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
653 ResponseCodes.FINAL_ACK_YES);
654 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
658 public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
659 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
660 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
661 serviceDeleteInput = builder.setCommonId(null).build();
662 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
663 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
664 ResponseCodes.FINAL_ACK_YES);
665 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
669 public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
670 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
671 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
672 serviceDeleteInput = builder.setSdncRequestHeader(null).build();
673 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
674 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
675 ResponseCodes.FINAL_ACK_YES);
676 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
680 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsNull()
681 throws ExecutionException, InterruptedException {
683 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
684 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
685 serviceDeleteInput = builder
686 .setSdncRequestHeader(
687 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId(null).build())
689 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
690 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
691 ResponseCodes.FINAL_ACK_YES);
692 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
696 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsEmpty()
697 throws ExecutionException, InterruptedException {
699 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
700 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
701 serviceDeleteInput = builder.setSdncRequestHeader(
702 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId("").build()).build();
703 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
704 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
705 ResponseCodes.FINAL_ACK_YES);
706 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
710 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNull()
711 throws ExecutionException, InterruptedException {
713 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
714 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
715 serviceDeleteInput = builder
716 .setSdncRequestHeader(
717 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRpcAction(null).build())
719 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
720 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
721 ResponseCodes.FINAL_ACK_YES);
722 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
726 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNotDelete()
727 throws ExecutionException, InterruptedException {
729 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
730 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
731 serviceDeleteInput = builder.setSdncRequestHeader(new SdncRequestHeaderBuilder(builder.getSdncRequestHeader())
732 .setRpcAction(RpcActions.ServiceCreate).build()).build();
733 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
734 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
735 ResponseCodes.FINAL_ACK_YES);
736 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
740 public void deleteServiceIfServiceHandlerCompliancyCheckNotPassed()
741 throws ExecutionException, InterruptedException {
743 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
745 Mockito.when(this.complianceCheckResultMock.hasPassed()).thenReturn(false);
747 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
748 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
749 ResponseCodes.FINAL_ACK_YES);
750 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
754 public void deleteServiceNotPresent() throws ExecutionException, InterruptedException {
756 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(ServiceDataUtils.buildServiceDeleteInput()).get()
758 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
759 ResponseCodes.FINAL_ACK_YES);
760 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
764 public void deleteServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
766 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
767 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
768 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
769 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
770 ResponseCodes.FINAL_ACK_YES);
771 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
775 public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
776 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
777 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
778 TempServiceDeleteOutput result =
779 this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
780 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
781 ResponseCodes.FINAL_ACK_YES);
782 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
786 public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
787 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
788 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
789 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
790 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
791 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
792 new ServiceInput(serviceDeleteInput));
793 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
794 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
795 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("Renderer service delete failed !")
797 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
798 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
799 .setConfigurationResponseCommon(configurationResponseCommon).build();
800 Mockito.when(this.rendererServiceWrapperMock.performRenderer(input,
801 ServiceNotificationTypes.ServiceDeleteResult)).thenReturn(output);
802 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
803 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
804 ResponseCodes.FINAL_ACK_YES);
805 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
809 public void deleteServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
810 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
811 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
812 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
813 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
814 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
815 new ServiceInput(serviceDeleteInput));
816 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
817 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
818 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress")
820 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
821 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
822 .rev171017.ServiceDeleteOutputBuilder()
823 .setConfigurationResponseCommon(configurationResponseCommon).build();
825 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
827 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
828 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
829 ResponseCodes.FINAL_ACK_NO);
830 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
834 public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
835 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
836 ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
837 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
838 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
843 public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
844 ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
845 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
846 Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null);
847 Optional<Services> service = Optional.of(serviceMock);
848 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
849 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
850 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
851 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
852 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
853 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Service reroute successfully !")
855 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
856 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
857 .rev171017.ServiceDeleteOutputBuilder()
858 .setConfigurationResponseCommon(configurationResponseCommon).build();
860 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
862 ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
863 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
865 Assert.assertEquals("Service reroute successfully !", result.getStatusMessage());