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.common.types.rev161014.State;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationInput;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
87 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
88 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
89 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
90 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
91 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
92 import org.opendaylight.yangtools.concepts.ListenerRegistration;
93 import org.opendaylight.yangtools.yang.common.RpcResult;
94 import org.slf4j.Logger;
95 import org.slf4j.LoggerFactory;
97 public class ServiceHandlerImplTest extends AbstractTest {
99 private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerImplTest.class);
100 private static final int NUMBER_OF_THREADS = 4;
102 private PathComputationService pathComputationService;
103 private RendererServiceOperations rendererServiceOperations;
104 private ServicehandlerImpl serviceHandler;
105 private PceListenerImpl pceListenerImpl;
106 private RendererListenerImpl rendererListenerImpl;
107 private ListeningExecutorService executor;
108 private NotificationPublishService notificationPublishService;
109 private NotificationService notificationService;
110 private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
111 private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
112 private MockedNotificationServiceWrapper mockedNotificationServiceWrapper;
115 private ServiceDataStoreOperations serviceDataStoreOperationsMock;
117 private PCEServiceWrapper pceServiceWrapperMock;
119 private RendererServiceWrapper rendererServiceWrapperMock;
121 private PathComputationService pathComputationServiceMock;
123 private RendererServiceOperations rendererServiceOperationsMock;
125 private ComplianceCheckResult complianceCheckResultMock;
127 private Optional<Services> servicesOptionalMock;
129 private PceListenerImpl pceListenerImplMock;
131 private RendererListenerImpl rendererListenerImplMock;
133 private NotificationPublishService notificationPublishServiceMock;
135 private NetworkModelWavelengthService networkModelWavelengthServiceMock;
137 private ServicehandlerImpl serviceHandlerImplMock;
140 public void setUp() {
141 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
142 this.rendererServiceOperations, this.notificationPublishService, this.pceListenerImpl,
143 this.rendererListenerImpl, this.networkModelWavelengthServiceMock);
144 this.serviceHandlerImplMock =
145 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, this.rendererServiceOperations,
146 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
147 MockitoAnnotations.initMocks(this);
150 public ServiceHandlerImplTest() throws Exception {
151 this.mockedNotificationServiceWrapper = new MockedNotificationServiceWrapper(getNotificationPublishService());
152 this.notificationPublishService = this.mockedNotificationServiceWrapper.getMockedNotificationService();
153 this.notificationService = getNotificationService();
154 this.pathComputationService = new StubPceServiceOperations(notificationPublishService);
155 this.rendererServiceOperations = new StubRendererServiceOperations(this.networkModelWavelengthServiceMock,
156 getDataBroker(), notificationPublishService);
157 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
158 "topologyData/NW-simple-topology.xml");
159 this.pceListenerImpl =
160 new PceListenerImpl(rendererServiceOperations, pathComputationService, notificationPublishService,
162 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
163 this.pceListenerImpl.setServiceReconfigure(false);
164 this.rendererListenerImpl =
165 new RendererListenerImpl(pathComputationServiceMock, notificationPublishService);
166 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
167 this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
168 pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
169 rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
175 public void testCreateServiceValid() throws ExecutionException, InterruptedException {
176 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
177 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
178 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
179 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
180 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
181 PceTestData.getPCE_simpletopology_test1_result((long) 5))
182 .setConfigurationResponseCommon(configurationResponseCommon).build();
183 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
184 .thenReturn(pathComputationRequestOutput);
185 Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
186 Assert.assertNotNull(output0);
187 Assert.assertTrue(output0.get().isSuccessful());
188 Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
189 ResponseCodes.FINAL_ACK_NO,"PCE calculation in progress", ResponseCodes.RESPONSE_OK)
191 Assert.assertEquals(0, output0.get().getErrors().size());
195 public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
196 ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
197 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyServiceNameInput);
198 emptyServiceNameInput = builtInput.setServiceName("").build();
199 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
200 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
201 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
206 public void createServiceHandlerInvalidIfNameIsNull() throws ExecutionException, InterruptedException {
207 ServiceCreateInput nullServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
208 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(nullServiceNameInput);
209 nullServiceNameInput = builtInput.setServiceName(null).build();
210 Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
211 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
212 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
217 public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
218 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
219 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
220 emptyServiceNameInput = builtInput.setCommonId("").build();
221 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
222 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
223 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
228 public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
229 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
230 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
231 emptyServiceNameInput = builtInput.setCommonId(null).build();
232 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
233 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
234 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
239 public void createServiceHnadlerInvalidIfConTypeIsEmpty() throws ExecutionException, InterruptedException {
240 ServiceCreateInput emptyConTypeInput = ServiceDataUtils.buildServiceCreateInput();
241 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyConTypeInput);
242 emptyConTypeInput = builtInput.setConnectionType(null).build();
243 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyConTypeInput).get().getResult(),
244 ModelMappingUtils.createCreateServiceReply(emptyConTypeInput, ResponseCodes.FINAL_ACK_YES,
245 "Service ConnectionType is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
249 public void createServiceHandlerInvalidIfSdncRequestHeaderNull() throws ExecutionException, InterruptedException {
250 ServiceCreateInput emptySdncRequestHeader = ServiceDataUtils.buildServiceCreateInput();
251 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptySdncRequestHeader);
252 emptySdncRequestHeader = buildInput.setSdncRequestHeader(null).build();
253 ServiceCreateOutput result = this.serviceHandler.serviceCreate(emptySdncRequestHeader).get().getResult();
254 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
255 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
256 ResponseCodes.FINAL_ACK_YES);
260 public void createServiceHandlerInvalidIfRequestIdEmpty() throws ExecutionException, InterruptedException {
261 ServiceCreateInput emptyRequestId = ServiceDataUtils.buildServiceCreateInput();
262 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyRequestId);
263 emptyRequestId = buildInput
264 .setSdncRequestHeader(
265 new SdncRequestHeaderBuilder(emptyRequestId.getSdncRequestHeader()).setRequestId("").build())
267 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyRequestId).get().getResult(),
269 .createCreateServiceReply(emptyRequestId, ResponseCodes.FINAL_ACK_YES,
270 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
275 public void createServiceHandlerInvalidIfRequestIdNull() throws ExecutionException, InterruptedException {
276 ServiceCreateInput nullRequestId = ServiceDataUtils.buildServiceCreateInput();
277 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(nullRequestId);
278 nullRequestId = buildInput
279 .setSdncRequestHeader(
280 new SdncRequestHeaderBuilder(nullRequestId.getSdncRequestHeader()).setRequestId(null).build())
282 Assert.assertEquals(this.serviceHandler.serviceCreate(nullRequestId).get().getResult(),
284 .createCreateServiceReply(nullRequestId, ResponseCodes.FINAL_ACK_YES,
285 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
290 public void serviceHandlerInvalidServiceActionIsNull() throws ExecutionException, InterruptedException {
291 ServiceCreateInput emptyServiceAction = ServiceDataUtils.buildServiceCreateInput();
292 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyServiceAction);
293 emptyServiceAction = buildInput.setSdncRequestHeader(
294 new SdncRequestHeaderBuilder(emptyServiceAction.getSdncRequestHeader()).setRpcAction(null).build())
296 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceAction).get().getResult(),
298 .createCreateServiceReply(emptyServiceAction, ResponseCodes.FINAL_ACK_YES,
299 "Service sndc-request-header 'rpc-action' is not set ", ResponseCodes.RESPONSE_FAILED)
304 public void serviceHandlerInvalidServiceActionIsNotCreate() throws ExecutionException, InterruptedException {
305 ServiceCreateInput notCreateServiceAction = ServiceDataUtils.buildServiceCreateInput();
306 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notCreateServiceAction);
307 notCreateServiceAction = buildInput
308 .setSdncRequestHeader(new SdncRequestHeaderBuilder(notCreateServiceAction.getSdncRequestHeader())
309 .setRpcAction(RpcActions.ServiceFeasibilityCheck).build())
311 Assert.assertEquals(this.serviceHandler.serviceCreate(notCreateServiceAction).get().getResult(),
312 ModelMappingUtils.createCreateServiceReply(notCreateServiceAction, ResponseCodes.FINAL_ACK_YES,
313 "Service sdncRequestHeader rpc-action '"
314 + notCreateServiceAction.getSdncRequestHeader().getRpcAction() + "' not equal to '"
315 + RpcActions.ServiceCreate.name() + "'",
316 ResponseCodes.RESPONSE_FAILED).get().getResult());
320 public void createServiceHandlerNotValidServiceAEndIsNull() throws ExecutionException, InterruptedException {
321 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
322 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
323 notValidServiceAEnd = buildInput.setServiceAEnd(null).build();
324 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
325 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
326 "SERVICEAEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
330 public void createServiceHandlerNotValidServiceZEndIsNull() throws ExecutionException, InterruptedException {
331 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
332 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
333 notValidServiceAEnd = buildInput.setServiceZEnd(null).build();
334 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
335 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
336 "SERVICEZEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
340 public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
341 ServicehandlerImpl servicehandler =
342 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
343 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
344 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
345 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
347 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceAEnd).get().getResult(),
348 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
349 "Service " + ServiceEndpointType.SERVICEAEND + " rate is not set",
350 ResponseCodes.RESPONSE_FAILED).get().getResult());
354 public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
355 ServicehandlerImpl servicehandler =
356 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
357 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
358 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
359 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
361 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceZEnd).get().getResult(),
362 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
363 "Service " + ServiceEndpointType.SERVICEZEND + " rate is not set",
364 ResponseCodes.RESPONSE_FAILED).get().getResult());
368 public void createServiceHandlerNotValidServiceAEndClliIsNull()
369 throws ExecutionException, InterruptedException {
370 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
371 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
372 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setClli(null)
374 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
375 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
376 "Service" + ServiceEndpointType.SERVICEAEND + " clli format is not set",
377 ResponseCodes.RESPONSE_FAILED).get().getResult());
381 public void createServiceHandlerNotValidServiceZEndClliIsNull()
382 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
383 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
384 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
385 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setClli(null).build())
387 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceZEnd).get().getResult(),
388 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
389 "Service" + ServiceEndpointType.SERVICEZEND + " clli format is not set",
390 ResponseCodes.RESPONSE_FAILED).get().getResult());
394 public void createServiceHandlerNotValidServiceAEndAttributes()
395 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
396 HashMap<String, Object> notValidData = new HashMap<>();
397 notValidData.put("setServiceRate", 0L);
398 notValidData.put("setServiceFormat", null);
399 notValidData.put("setClli", "");
400 notValidData.put("setTxDirection", null);
401 notValidData.put("setRxDirection", null);
402 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
403 .ServiceAEndBuilder.class.getDeclaredMethods()) {
404 if (notValidData.containsKey(method.getName())) {
405 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
406 .buildServiceCreateInput());
407 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
408 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
409 method.invoke(serviceAEndBuilder, notValidData.get(method.getName()));
410 ServiceCreateOutput result = this.serviceHandler
411 .serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get().getResult();
412 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
413 ResponseCodes.FINAL_ACK_YES);
414 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
415 ResponseCodes.RESPONSE_FAILED);
421 public void createServiceHandlerNotValidServiceZEndAttributes()
422 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
423 HashMap<String, Object> notValidData = new HashMap<>();
424 notValidData.put("setServiceRate", 0L);
425 notValidData.put("setServiceFormat", null);
426 notValidData.put("setClli", "");
427 notValidData.put("setTxDirection", null);
428 notValidData.put("setRxDirection", null);
429 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
430 .ServiceZEndBuilder.class.getDeclaredMethods()) {
431 if (notValidData.containsKey(method.getName())) {
432 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
433 .buildServiceCreateInput());
434 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
435 .ServiceZEndBuilder serviceZEndBuilder = ServiceDataUtils.getServiceZEndBuild();
436 method.invoke(serviceZEndBuilder, notValidData.get(method.getName()));
437 ServiceCreateOutput result = this.serviceHandler
438 .serviceCreate(buildInput.setServiceZEnd(serviceZEndBuilder.build()).build()).get().getResult();
439 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
440 ResponseCodes.FINAL_ACK_YES);
441 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
442 ResponseCodes.RESPONSE_FAILED);
448 public void createServiceHandlerNotValidTxDirectionPort()
449 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
450 List<String> invalidData = Arrays.asList(null, "");
451 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
452 for (Method method : PortBuilder.class.getMethods()) {
453 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
454 for (Object data : invalidData) {
455 PortBuilder portBuilder = new PortBuilder(
456 serviceCreateInput.getServiceAEnd().getTxDirection().getPort());
457 method.invoke(portBuilder, data);
458 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(portBuilder.build(),
459 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
460 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
461 ResponseCodes.FINAL_ACK_YES);
462 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
463 ResponseCodes.RESPONSE_FAILED);
470 public void createServiceHandlerTxDirectionPortIsNull() throws ExecutionException, InterruptedException {
471 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(null,
472 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getLgx());
473 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
474 ResponseCodes.FINAL_ACK_YES);
475 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
479 public void createServiceHandlerNotValidTxDirectionLgx()
480 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
481 List<String> invalidData = Arrays.asList(null, "");
482 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
483 for (Method method : LgxBuilder.class.getMethods()) {
484 if (method.getName().startsWith("set")) {
485 for (Object data : invalidData) {
486 LgxBuilder lgxBuilder = new LgxBuilder(
487 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
488 method.invoke(lgxBuilder, data);
489 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
490 serviceCreateInput.getServiceAEnd().getTxDirection().getPort(), lgxBuilder.build());
491 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
492 ResponseCodes.FINAL_ACK_YES);
493 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
494 ResponseCodes.RESPONSE_FAILED);
501 public void createServiceHandlerTxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
502 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
503 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getPort(), null);
504 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
505 ResponseCodes.FINAL_ACK_YES);
506 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
509 private ServiceCreateOutput getTxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
510 throws InterruptedException, ExecutionException {
511 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
512 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
513 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
514 TxDirectionBuilder txDirectionBuilder = new TxDirectionBuilder(
515 serviceCreateInput.getServiceAEnd().getTxDirection());
516 txDirectionBuilder.setPort(port);
517 txDirectionBuilder.setLgx(lgx);
518 serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
519 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
520 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
522 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
527 public void createServiceHandlerNotValidRxDirectionPort()
528 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
529 List<String> invalidData = Arrays.asList(null, "");
530 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
531 for (Method method : PortBuilder.class.getMethods()) {
532 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
533 for (Object data : invalidData) {
534 PortBuilder portBuilder = new PortBuilder(
535 serviceCreateInput.getServiceAEnd().getRxDirection().getPort());
536 method.invoke(portBuilder, data);
537 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(portBuilder.build(),
538 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
539 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
540 ResponseCodes.FINAL_ACK_YES);
541 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
542 ResponseCodes.RESPONSE_FAILED);
549 public void createServiceHandlerRxDirectionPortIsNull()
550 throws ExecutionException, InterruptedException {
551 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(null,
552 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getLgx());
553 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
554 ResponseCodes.FINAL_ACK_YES);
555 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
559 public void createServiceHandlerNotValidRxDirectionLgx()
560 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
561 List<String> invalidData = Arrays.asList(null, "");
562 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
563 for (Method method : LgxBuilder.class.getMethods()) {
564 if (method.getName().startsWith("set")) {
565 for (Object data : invalidData) {
566 LgxBuilder lgxBuilder = new LgxBuilder(
567 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
568 method.invoke(lgxBuilder, data);
569 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
570 serviceCreateInput.getServiceAEnd().getRxDirection().getPort(), lgxBuilder.build());
571 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
572 ResponseCodes.FINAL_ACK_YES);
573 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
574 ResponseCodes.RESPONSE_FAILED);
581 public void createServiceHandlerRxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
582 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
583 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getPort(), null);
584 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
585 ResponseCodes.FINAL_ACK_YES);
586 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
590 public void createServiceHandlerResponseCodesNotPassed() throws ExecutionException, InterruptedException {
591 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
592 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
593 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
594 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("PCE calculation failed").build();
595 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
596 PceTestData.getPCE_simpletopology_test1_result((long) 5))
597 .setConfigurationResponseCommon(configurationResponseCommon).build();
598 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
599 .thenReturn(pathComputationRequestOutput);
600 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
601 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
604 private ServiceCreateOutput getRxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
605 throws InterruptedException, ExecutionException {
606 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
607 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
608 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
609 RxDirectionBuilder rxDirectionBuilder = new RxDirectionBuilder(
610 serviceCreateInput.getServiceAEnd().getRxDirection());
611 rxDirectionBuilder.setPort(port);
612 rxDirectionBuilder.setLgx(lgx);
613 serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
614 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
615 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
617 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
622 public void deleteServiceInvalidIfServiceNameIsEmpty() throws ExecutionException, InterruptedException {
624 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
625 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
626 serviceDeleteInput = builder
627 .setServiceDeleteReqInfo(
628 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName("").build())
630 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
631 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
632 ResponseCodes.FINAL_ACK_YES);
633 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
637 public void deleteServiceInvalidIfServiceNameIsNull() throws ExecutionException, InterruptedException {
639 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
640 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
641 serviceDeleteInput = builder
642 .setServiceDeleteReqInfo(
643 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName(null).build())
645 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
646 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
647 ResponseCodes.FINAL_ACK_YES);
648 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
652 public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
653 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
654 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
655 serviceDeleteInput = builder.setCommonId("").build();
656 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
657 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
658 ResponseCodes.FINAL_ACK_YES);
659 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
663 public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
664 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
665 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
666 serviceDeleteInput = builder.setCommonId(null).build();
667 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
668 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
669 ResponseCodes.FINAL_ACK_YES);
670 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
674 public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
675 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
676 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
677 serviceDeleteInput = builder.setSdncRequestHeader(null).build();
678 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
679 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
680 ResponseCodes.FINAL_ACK_YES);
681 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
685 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsNull()
686 throws ExecutionException, InterruptedException {
688 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
689 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
690 serviceDeleteInput = builder
691 .setSdncRequestHeader(
692 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId(null).build())
694 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
695 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
696 ResponseCodes.FINAL_ACK_YES);
697 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
701 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsEmpty()
702 throws ExecutionException, InterruptedException {
704 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
705 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
706 serviceDeleteInput = builder.setSdncRequestHeader(
707 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId("").build()).build();
708 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
709 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
710 ResponseCodes.FINAL_ACK_YES);
711 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
715 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNull()
716 throws ExecutionException, InterruptedException {
718 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
719 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
720 serviceDeleteInput = builder
721 .setSdncRequestHeader(
722 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRpcAction(null).build())
724 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
725 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
726 ResponseCodes.FINAL_ACK_YES);
727 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
731 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNotDelete()
732 throws ExecutionException, InterruptedException {
734 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
735 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
736 serviceDeleteInput = builder.setSdncRequestHeader(new SdncRequestHeaderBuilder(builder.getSdncRequestHeader())
737 .setRpcAction(RpcActions.ServiceCreate).build()).build();
738 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
739 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
740 ResponseCodes.FINAL_ACK_YES);
741 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
745 public void deleteServiceIfServiceHandlerCompliancyCheckNotPassed()
746 throws ExecutionException, InterruptedException {
748 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
750 Mockito.when(this.complianceCheckResultMock.hasPassed()).thenReturn(false);
752 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
753 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
754 ResponseCodes.FINAL_ACK_YES);
755 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
759 public void deleteServiceNotPresent() throws ExecutionException, InterruptedException {
761 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(ServiceDataUtils.buildServiceDeleteInput()).get()
763 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
764 ResponseCodes.FINAL_ACK_YES);
765 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
769 public void deleteServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
771 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
772 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
773 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
774 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
775 ResponseCodes.FINAL_ACK_YES);
776 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
780 public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
781 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
782 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
783 TempServiceDeleteOutput result =
784 this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
785 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
786 ResponseCodes.FINAL_ACK_YES);
787 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
791 public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
792 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
793 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
794 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
795 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
796 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
797 new ServiceInput(serviceDeleteInput));
798 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
799 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
800 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("Renderer service delete failed !")
802 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
803 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
804 .setConfigurationResponseCommon(configurationResponseCommon).build();
805 Mockito.when(this.rendererServiceWrapperMock.performRenderer(input,
806 ServiceNotificationTypes.ServiceDeleteResult)).thenReturn(output);
807 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
808 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
809 ResponseCodes.FINAL_ACK_YES);
810 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
814 public void deleteServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
815 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
816 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
817 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
818 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
819 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
820 new ServiceInput(serviceDeleteInput));
821 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
822 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
823 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress")
825 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
826 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
827 .rev171017.ServiceDeleteOutputBuilder()
828 .setConfigurationResponseCommon(configurationResponseCommon).build();
830 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
832 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
833 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
834 ResponseCodes.FINAL_ACK_NO);
835 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
839 public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
840 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
841 ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
842 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
843 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
848 public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
849 ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
850 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
851 Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null);
852 Optional<Services> service = Optional.of(serviceMock);
853 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
854 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
855 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
856 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
857 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
858 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress")
860 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
861 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
862 .rev171017.ServiceDeleteOutputBuilder()
863 .setConfigurationResponseCommon(configurationResponseCommon).build();
865 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
867 ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
868 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
870 Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());
874 public void reConfigureServiceIfserviceNotPresent() throws ExecutionException, InterruptedException {
875 ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
876 ServiceReconfigureOutput result = this.serviceHandler.serviceReconfigure(input).get().getResult();
877 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
878 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
882 public void reConfigureServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
883 ServiceReconfigureInput serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
884 Services serviceMock = ModelMappingUtils.mappingServices(null, serviceReconfigureInput);
885 Optional<Services> service = Optional.of(serviceMock);
886 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
887 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput input =
888 ModelMappingUtils.createServiceDeleteInput(serviceReconfigureInput);
889 ConfigurationResponseCommon configurationResponseCommon =
890 new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
891 .setRequestId("1").setResponseCode(ResponseCodes.RESPONSE_OK)
892 .setResponseMessage("Renderer service delete in progress").build();
893 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput output =
894 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
895 .ServiceDeleteOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon).build();
897 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
899 ServiceReconfigureOutput result =
900 this.serviceHandlerImplMock.serviceReconfigure(serviceReconfigureInput).get().getResult();
901 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
903 Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());
907 public void restorationServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
908 ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
909 ServiceRestorationOutput result = this.serviceHandler.serviceRestoration(input).get().getResult();
910 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
911 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
915 public void restorationServiceIfServiceNotDown() throws ExecutionException, InterruptedException {
916 ServiceRestorationInput input = ServiceDataUtils.buildServiceRestorationInput();
917 Services serviceMock = ModelMappingUtils.mappingServices(ServiceDataUtils.buildServiceCreateInput(), null);
918 ServicesBuilder builder = new ServicesBuilder(serviceMock).setAdministrativeState(State.InService)
919 .setOperationalState(State.InService);
920 Optional<Services> service = Optional.of(builder.build());
921 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
922 ServiceRestorationOutput result = this.serviceHandlerImplMock.serviceRestoration(input).get().getResult();
923 Assert.assertEquals(RpcStatus.Failed, result.getStatus());
924 Assert.assertEquals("Service 'service 1' is in 'inService' state", result.getStatusMessage());
928 public void restorationServiceIfServicePresentAndDown() throws ExecutionException, InterruptedException {
929 ServiceRestorationInput serviceRestorationInput = ServiceDataUtils.buildServiceRestorationInput();
930 Services serviceMock = ModelMappingUtils.mappingServices(ServiceDataUtils.buildServiceCreateInput(), null);
931 ServicesBuilder builder = new ServicesBuilder(serviceMock).setAdministrativeState(State.OutOfService)
932 .setOperationalState(State.OutOfService);
933 Optional<Services> service = Optional.of(builder.build());
934 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
935 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput input =
936 ModelMappingUtils.createServiceDeleteInput(serviceRestorationInput, serviceMock);
937 ConfigurationResponseCommon configurationResponseCommon =
938 new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
939 .setRequestId("1").setResponseCode(ResponseCodes.RESPONSE_OK)
940 .setResponseMessage("Renderer service delete in progress").build();
941 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput output =
942 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
943 .ServiceDeleteOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon).build();
945 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
947 ServiceRestorationOutput result =
948 this.serviceHandlerImplMock.serviceRestoration(serviceRestorationInput).get().getResult();
949 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
951 Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());