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.ServiceReconfigureInput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
87 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
88 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
89 import org.opendaylight.yangtools.concepts.ListenerRegistration;
90 import org.opendaylight.yangtools.yang.common.RpcResult;
91 import org.slf4j.Logger;
92 import org.slf4j.LoggerFactory;
94 public class ServiceHandlerImplTest extends AbstractTest {
96 private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerImplTest.class);
97 private static final int NUMBER_OF_THREADS = 4;
99 private PathComputationService pathComputationService;
100 private RendererServiceOperations rendererServiceOperations;
101 private ServicehandlerImpl serviceHandler;
102 private PceListenerImpl pceListenerImpl;
103 private RendererListenerImpl rendererListenerImpl;
104 private ListeningExecutorService executor;
105 private NotificationPublishService notificationPublishService;
106 private NotificationService notificationService;
107 private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
108 private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
109 private MockedNotificationServiceWrapper mockedNotificationServiceWrapper;
112 private ServiceDataStoreOperations serviceDataStoreOperationsMock;
114 private PCEServiceWrapper pceServiceWrapperMock;
116 private RendererServiceWrapper rendererServiceWrapperMock;
118 private PathComputationService pathComputationServiceMock;
120 private RendererServiceOperations rendererServiceOperationsMock;
122 private ComplianceCheckResult complianceCheckResultMock;
124 private Optional<Services> servicesOptionalMock;
126 private PceListenerImpl pceListenerImplMock;
128 private RendererListenerImpl rendererListenerImplMock;
130 private NotificationPublishService notificationPublishServiceMock;
132 private NetworkModelWavelengthService networkModelWavelengthServiceMock;
134 private ServicehandlerImpl serviceHandlerImplMock;
137 public void setUp() {
138 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
139 this.rendererServiceOperations, this.notificationPublishService, this.pceListenerImpl,
140 this.rendererListenerImpl, this.networkModelWavelengthServiceMock);
141 this.serviceHandlerImplMock =
142 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, this.rendererServiceOperations,
143 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
144 MockitoAnnotations.initMocks(this);
147 public ServiceHandlerImplTest() throws Exception {
148 this.mockedNotificationServiceWrapper = new MockedNotificationServiceWrapper(getNotificationPublishService());
149 this.notificationPublishService = this.mockedNotificationServiceWrapper.getMockedNotificationService();
150 this.notificationService = getNotificationService();
151 this.pathComputationService = new StubPceServiceOperations(notificationPublishService);
152 this.rendererServiceOperations = new StubRendererServiceOperations(this.networkModelWavelengthServiceMock,
153 getDataBroker(), notificationPublishService);
154 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
155 "topologyData/NW-simple-topology.xml");
156 this.pceListenerImpl =
157 new PceListenerImpl(rendererServiceOperations, pathComputationService, notificationPublishService,
159 this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
160 this.pceListenerImpl.setServiceReconfigure(false);
161 this.rendererListenerImpl =
162 new RendererListenerImpl(pathComputationServiceMock, notificationPublishService);
163 this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperationsMock);
164 this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS));
165 pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
166 rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
172 public void testCreateServiceValid() throws ExecutionException, InterruptedException {
173 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
174 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
175 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
176 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
177 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
178 PceTestData.getPCE_simpletopology_test1_result((long) 5))
179 .setConfigurationResponseCommon(configurationResponseCommon).build();
180 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
181 .thenReturn(pathComputationRequestOutput);
182 Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
183 Assert.assertNotNull(output0);
184 Assert.assertTrue(output0.get().isSuccessful());
185 Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
186 ResponseCodes.FINAL_ACK_NO,"PCE calculation in progress", ResponseCodes.RESPONSE_OK)
188 Assert.assertEquals(0, output0.get().getErrors().size());
192 public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
193 ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
194 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyServiceNameInput);
195 emptyServiceNameInput = builtInput.setServiceName("").build();
196 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
197 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
198 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
203 public void createServiceHandlerInvalidIfNameIsNull() throws ExecutionException, InterruptedException {
204 ServiceCreateInput nullServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
205 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(nullServiceNameInput);
206 nullServiceNameInput = builtInput.setServiceName(null).build();
207 Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
208 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
209 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
214 public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
215 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
216 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
217 emptyServiceNameInput = builtInput.setCommonId("").build();
218 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
219 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
220 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
225 public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
226 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
227 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
228 emptyServiceNameInput = builtInput.setCommonId(null).build();
229 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
230 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
231 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
236 public void createServiceHnadlerInvalidIfConTypeIsEmpty() throws ExecutionException, InterruptedException {
237 ServiceCreateInput emptyConTypeInput = ServiceDataUtils.buildServiceCreateInput();
238 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyConTypeInput);
239 emptyConTypeInput = builtInput.setConnectionType(null).build();
240 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyConTypeInput).get().getResult(),
241 ModelMappingUtils.createCreateServiceReply(emptyConTypeInput, ResponseCodes.FINAL_ACK_YES,
242 "Service ConnectionType is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
246 public void createServiceHandlerInvalidIfSdncRequestHeaderNull() throws ExecutionException, InterruptedException {
247 ServiceCreateInput emptySdncRequestHeader = ServiceDataUtils.buildServiceCreateInput();
248 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptySdncRequestHeader);
249 emptySdncRequestHeader = buildInput.setSdncRequestHeader(null).build();
250 ServiceCreateOutput result = this.serviceHandler.serviceCreate(emptySdncRequestHeader).get().getResult();
251 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
252 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
253 ResponseCodes.FINAL_ACK_YES);
257 public void createServiceHandlerInvalidIfRequestIdEmpty() throws ExecutionException, InterruptedException {
258 ServiceCreateInput emptyRequestId = ServiceDataUtils.buildServiceCreateInput();
259 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyRequestId);
260 emptyRequestId = buildInput
261 .setSdncRequestHeader(
262 new SdncRequestHeaderBuilder(emptyRequestId.getSdncRequestHeader()).setRequestId("").build())
264 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyRequestId).get().getResult(),
266 .createCreateServiceReply(emptyRequestId, ResponseCodes.FINAL_ACK_YES,
267 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
272 public void createServiceHandlerInvalidIfRequestIdNull() throws ExecutionException, InterruptedException {
273 ServiceCreateInput nullRequestId = ServiceDataUtils.buildServiceCreateInput();
274 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(nullRequestId);
275 nullRequestId = buildInput
276 .setSdncRequestHeader(
277 new SdncRequestHeaderBuilder(nullRequestId.getSdncRequestHeader()).setRequestId(null).build())
279 Assert.assertEquals(this.serviceHandler.serviceCreate(nullRequestId).get().getResult(),
281 .createCreateServiceReply(nullRequestId, ResponseCodes.FINAL_ACK_YES,
282 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
287 public void serviceHandlerInvalidServiceActionIsNull() throws ExecutionException, InterruptedException {
288 ServiceCreateInput emptyServiceAction = ServiceDataUtils.buildServiceCreateInput();
289 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyServiceAction);
290 emptyServiceAction = buildInput.setSdncRequestHeader(
291 new SdncRequestHeaderBuilder(emptyServiceAction.getSdncRequestHeader()).setRpcAction(null).build())
293 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceAction).get().getResult(),
295 .createCreateServiceReply(emptyServiceAction, ResponseCodes.FINAL_ACK_YES,
296 "Service sndc-request-header 'rpc-action' is not set ", ResponseCodes.RESPONSE_FAILED)
301 public void serviceHandlerInvalidServiceActionIsNotCreate() throws ExecutionException, InterruptedException {
302 ServiceCreateInput notCreateServiceAction = ServiceDataUtils.buildServiceCreateInput();
303 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notCreateServiceAction);
304 notCreateServiceAction = buildInput
305 .setSdncRequestHeader(new SdncRequestHeaderBuilder(notCreateServiceAction.getSdncRequestHeader())
306 .setRpcAction(RpcActions.ServiceFeasibilityCheck).build())
308 Assert.assertEquals(this.serviceHandler.serviceCreate(notCreateServiceAction).get().getResult(),
309 ModelMappingUtils.createCreateServiceReply(notCreateServiceAction, ResponseCodes.FINAL_ACK_YES,
310 "Service sdncRequestHeader rpc-action '"
311 + notCreateServiceAction.getSdncRequestHeader().getRpcAction() + "' not equal to '"
312 + RpcActions.ServiceCreate.name() + "'",
313 ResponseCodes.RESPONSE_FAILED).get().getResult());
317 public void createServiceHandlerNotValidServiceAEndIsNull() throws ExecutionException, InterruptedException {
318 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
319 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
320 notValidServiceAEnd = buildInput.setServiceAEnd(null).build();
321 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
322 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
323 "SERVICEAEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
327 public void createServiceHandlerNotValidServiceZEndIsNull() throws ExecutionException, InterruptedException {
328 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
329 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
330 notValidServiceAEnd = buildInput.setServiceZEnd(null).build();
331 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
332 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
333 "SERVICEZEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
337 public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
338 ServicehandlerImpl servicehandler =
339 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
340 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
341 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
342 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
344 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceAEnd).get().getResult(),
345 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
346 "Service " + ServiceEndpointType.SERVICEAEND + " rate is not set",
347 ResponseCodes.RESPONSE_FAILED).get().getResult());
351 public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
352 ServicehandlerImpl servicehandler =
353 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null, null, null);
354 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
355 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
356 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
358 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceZEnd).get().getResult(),
359 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
360 "Service " + ServiceEndpointType.SERVICEZEND + " rate is not set",
361 ResponseCodes.RESPONSE_FAILED).get().getResult());
365 public void createServiceHandlerNotValidServiceAEndClliIsNull()
366 throws ExecutionException, InterruptedException {
367 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
368 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
369 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setClli(null)
371 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
372 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
373 "Service" + ServiceEndpointType.SERVICEAEND + " clli format is not set",
374 ResponseCodes.RESPONSE_FAILED).get().getResult());
378 public void createServiceHandlerNotValidServiceZEndClliIsNull()
379 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
380 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
381 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
382 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setClli(null).build())
384 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceZEnd).get().getResult(),
385 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
386 "Service" + ServiceEndpointType.SERVICEZEND + " clli format is not set",
387 ResponseCodes.RESPONSE_FAILED).get().getResult());
391 public void createServiceHandlerNotValidServiceAEndAttributes()
392 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
393 HashMap<String, Object> notValidData = new HashMap<>();
394 notValidData.put("setServiceRate", 0L);
395 notValidData.put("setServiceFormat", null);
396 notValidData.put("setClli", "");
397 notValidData.put("setTxDirection", null);
398 notValidData.put("setRxDirection", null);
399 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
400 .ServiceAEndBuilder.class.getDeclaredMethods()) {
401 if (notValidData.containsKey(method.getName())) {
402 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
403 .buildServiceCreateInput());
404 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
405 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
406 method.invoke(serviceAEndBuilder, notValidData.get(method.getName()));
407 ServiceCreateOutput result = this.serviceHandler
408 .serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get().getResult();
409 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
410 ResponseCodes.FINAL_ACK_YES);
411 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
412 ResponseCodes.RESPONSE_FAILED);
418 public void createServiceHandlerNotValidServiceZEndAttributes()
419 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
420 HashMap<String, Object> notValidData = new HashMap<>();
421 notValidData.put("setServiceRate", 0L);
422 notValidData.put("setServiceFormat", null);
423 notValidData.put("setClli", "");
424 notValidData.put("setTxDirection", null);
425 notValidData.put("setRxDirection", null);
426 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
427 .ServiceZEndBuilder.class.getDeclaredMethods()) {
428 if (notValidData.containsKey(method.getName())) {
429 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
430 .buildServiceCreateInput());
431 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
432 .ServiceZEndBuilder serviceZEndBuilder = ServiceDataUtils.getServiceZEndBuild();
433 method.invoke(serviceZEndBuilder, notValidData.get(method.getName()));
434 ServiceCreateOutput result = this.serviceHandler
435 .serviceCreate(buildInput.setServiceZEnd(serviceZEndBuilder.build()).build()).get().getResult();
436 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
437 ResponseCodes.FINAL_ACK_YES);
438 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
439 ResponseCodes.RESPONSE_FAILED);
445 public void createServiceHandlerNotValidTxDirectionPort()
446 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
447 List<String> invalidData = Arrays.asList(null, "");
448 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
449 for (Method method : PortBuilder.class.getMethods()) {
450 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
451 for (Object data : invalidData) {
452 PortBuilder portBuilder = new PortBuilder(
453 serviceCreateInput.getServiceAEnd().getTxDirection().getPort());
454 method.invoke(portBuilder, data);
455 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(portBuilder.build(),
456 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
457 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
458 ResponseCodes.FINAL_ACK_YES);
459 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
460 ResponseCodes.RESPONSE_FAILED);
467 public void createServiceHandlerTxDirectionPortIsNull() throws ExecutionException, InterruptedException {
468 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(null,
469 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getLgx());
470 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
471 ResponseCodes.FINAL_ACK_YES);
472 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
476 public void createServiceHandlerNotValidTxDirectionLgx()
477 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
478 List<String> invalidData = Arrays.asList(null, "");
479 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
480 for (Method method : LgxBuilder.class.getMethods()) {
481 if (method.getName().startsWith("set")) {
482 for (Object data : invalidData) {
483 LgxBuilder lgxBuilder = new LgxBuilder(
484 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
485 method.invoke(lgxBuilder, data);
486 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
487 serviceCreateInput.getServiceAEnd().getTxDirection().getPort(), lgxBuilder.build());
488 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
489 ResponseCodes.FINAL_ACK_YES);
490 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
491 ResponseCodes.RESPONSE_FAILED);
498 public void createServiceHandlerTxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
499 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
500 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getPort(), null);
501 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
502 ResponseCodes.FINAL_ACK_YES);
503 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
506 private ServiceCreateOutput getTxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
507 throws InterruptedException, ExecutionException {
508 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
509 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
510 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
511 TxDirectionBuilder txDirectionBuilder = new TxDirectionBuilder(
512 serviceCreateInput.getServiceAEnd().getTxDirection());
513 txDirectionBuilder.setPort(port);
514 txDirectionBuilder.setLgx(lgx);
515 serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
516 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
517 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
519 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
524 public void createServiceHandlerNotValidRxDirectionPort()
525 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
526 List<String> invalidData = Arrays.asList(null, "");
527 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
528 for (Method method : PortBuilder.class.getMethods()) {
529 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
530 for (Object data : invalidData) {
531 PortBuilder portBuilder = new PortBuilder(
532 serviceCreateInput.getServiceAEnd().getRxDirection().getPort());
533 method.invoke(portBuilder, data);
534 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(portBuilder.build(),
535 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
536 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
537 ResponseCodes.FINAL_ACK_YES);
538 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
539 ResponseCodes.RESPONSE_FAILED);
546 public void createServiceHandlerRxDirectionPortIsNull()
547 throws ExecutionException, InterruptedException {
548 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(null,
549 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getLgx());
550 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
551 ResponseCodes.FINAL_ACK_YES);
552 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
556 public void createServiceHandlerNotValidRxDirectionLgx()
557 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
558 List<String> invalidData = Arrays.asList(null, "");
559 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
560 for (Method method : LgxBuilder.class.getMethods()) {
561 if (method.getName().startsWith("set")) {
562 for (Object data : invalidData) {
563 LgxBuilder lgxBuilder = new LgxBuilder(
564 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
565 method.invoke(lgxBuilder, data);
566 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
567 serviceCreateInput.getServiceAEnd().getRxDirection().getPort(), lgxBuilder.build());
568 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
569 ResponseCodes.FINAL_ACK_YES);
570 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
571 ResponseCodes.RESPONSE_FAILED);
578 public void createServiceHandlerRxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
579 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
580 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getPort(), null);
581 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
582 ResponseCodes.FINAL_ACK_YES);
583 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
587 public void createServiceHandlerResponseCodesNotPassed() throws ExecutionException, InterruptedException {
588 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
589 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
590 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
591 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("PCE calculation failed").build();
592 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
593 PceTestData.getPCE_simpletopology_test1_result((long) 5))
594 .setConfigurationResponseCommon(configurationResponseCommon).build();
595 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
596 .thenReturn(pathComputationRequestOutput);
597 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
598 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
601 private ServiceCreateOutput getRxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
602 throws InterruptedException, ExecutionException {
603 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
604 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
605 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
606 RxDirectionBuilder rxDirectionBuilder = new RxDirectionBuilder(
607 serviceCreateInput.getServiceAEnd().getRxDirection());
608 rxDirectionBuilder.setPort(port);
609 rxDirectionBuilder.setLgx(lgx);
610 serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
611 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
612 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null, null,
614 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
619 public void deleteServiceInvalidIfServiceNameIsEmpty() throws ExecutionException, InterruptedException {
621 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
622 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
623 serviceDeleteInput = builder
624 .setServiceDeleteReqInfo(
625 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName("").build())
627 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
628 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
629 ResponseCodes.FINAL_ACK_YES);
630 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
634 public void deleteServiceInvalidIfServiceNameIsNull() throws ExecutionException, InterruptedException {
636 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
637 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
638 serviceDeleteInput = builder
639 .setServiceDeleteReqInfo(
640 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName(null).build())
642 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
643 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
644 ResponseCodes.FINAL_ACK_YES);
645 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
649 public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
650 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
651 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
652 serviceDeleteInput = builder.setCommonId("").build();
653 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
654 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
655 ResponseCodes.FINAL_ACK_YES);
656 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
660 public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
661 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
662 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
663 serviceDeleteInput = builder.setCommonId(null).build();
664 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
665 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
666 ResponseCodes.FINAL_ACK_YES);
667 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
671 public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
672 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
673 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
674 serviceDeleteInput = builder.setSdncRequestHeader(null).build();
675 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
676 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
677 ResponseCodes.FINAL_ACK_YES);
678 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
682 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsNull()
683 throws ExecutionException, InterruptedException {
685 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
686 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
687 serviceDeleteInput = builder
688 .setSdncRequestHeader(
689 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId(null).build())
691 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
692 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
693 ResponseCodes.FINAL_ACK_YES);
694 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
698 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsEmpty()
699 throws ExecutionException, InterruptedException {
701 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
702 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
703 serviceDeleteInput = builder.setSdncRequestHeader(
704 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId("").build()).build();
705 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
706 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
707 ResponseCodes.FINAL_ACK_YES);
708 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
712 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNull()
713 throws ExecutionException, InterruptedException {
715 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
716 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
717 serviceDeleteInput = builder
718 .setSdncRequestHeader(
719 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRpcAction(null).build())
721 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
722 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
723 ResponseCodes.FINAL_ACK_YES);
724 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
728 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNotDelete()
729 throws ExecutionException, InterruptedException {
731 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
732 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
733 serviceDeleteInput = builder.setSdncRequestHeader(new SdncRequestHeaderBuilder(builder.getSdncRequestHeader())
734 .setRpcAction(RpcActions.ServiceCreate).build()).build();
735 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
736 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
737 ResponseCodes.FINAL_ACK_YES);
738 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
742 public void deleteServiceIfServiceHandlerCompliancyCheckNotPassed()
743 throws ExecutionException, InterruptedException {
745 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
747 Mockito.when(this.complianceCheckResultMock.hasPassed()).thenReturn(false);
749 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
750 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
751 ResponseCodes.FINAL_ACK_YES);
752 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
756 public void deleteServiceNotPresent() throws ExecutionException, InterruptedException {
758 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(ServiceDataUtils.buildServiceDeleteInput()).get()
760 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
761 ResponseCodes.FINAL_ACK_YES);
762 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
766 public void deleteServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
768 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
769 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
770 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
771 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
772 ResponseCodes.FINAL_ACK_YES);
773 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
777 public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
778 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
779 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
780 TempServiceDeleteOutput result =
781 this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
782 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
783 ResponseCodes.FINAL_ACK_YES);
784 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
788 public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
789 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
790 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
791 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
792 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
793 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
794 new ServiceInput(serviceDeleteInput));
795 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
796 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
797 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("Renderer service delete failed !")
799 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
800 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
801 .setConfigurationResponseCommon(configurationResponseCommon).build();
802 Mockito.when(this.rendererServiceWrapperMock.performRenderer(input,
803 ServiceNotificationTypes.ServiceDeleteResult)).thenReturn(output);
804 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
805 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
806 ResponseCodes.FINAL_ACK_YES);
807 Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
811 public void deleteServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
812 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
813 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
814 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
815 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
816 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
817 new ServiceInput(serviceDeleteInput));
818 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
819 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
820 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress")
822 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
823 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
824 .rev171017.ServiceDeleteOutputBuilder()
825 .setConfigurationResponseCommon(configurationResponseCommon).build();
827 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
829 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
830 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
831 ResponseCodes.FINAL_ACK_NO);
832 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
836 public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
837 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
838 ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
839 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
840 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
845 public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
846 ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
847 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
848 Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null);
849 Optional<Services> service = Optional.of(serviceMock);
850 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
851 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
852 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
853 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
854 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
855 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("Renderer service delete in progress")
857 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
858 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
859 .rev171017.ServiceDeleteOutputBuilder()
860 .setConfigurationResponseCommon(configurationResponseCommon).build();
862 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
864 ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
865 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
867 Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());
871 public void reConfigureServiceIfserviceNotPresent() throws ExecutionException, InterruptedException {
872 ServiceReconfigureInput input = ServiceDataUtils.buildServiceReconfigureInput();
873 ServiceReconfigureOutput result = this.serviceHandler.serviceReconfigure(input).get().getResult();
874 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
875 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
879 public void reConfigureServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
880 ServiceReconfigureInput serviceReconfigureInput = ServiceDataUtils.buildServiceReconfigureInput();
881 Services serviceMock = ModelMappingUtils.mappingServices(null, serviceReconfigureInput);
882 Optional<Services> service = Optional.of(serviceMock);
883 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
884 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput input =
885 ModelMappingUtils.createServiceDeleteInput(serviceReconfigureInput);
886 ConfigurationResponseCommon configurationResponseCommon =
887 new ConfigurationResponseCommonBuilder().setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES)
888 .setRequestId("1").setResponseCode(ResponseCodes.RESPONSE_OK)
889 .setResponseMessage("Renderer service delete in progress").build();
890 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput output =
891 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
892 .ServiceDeleteOutputBuilder().setConfigurationResponseCommon(configurationResponseCommon).build();
894 this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult))
896 ServiceReconfigureOutput result =
897 this.serviceHandlerImplMock.serviceReconfigure(serviceReconfigureInput).get().getResult();
898 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
900 Assert.assertEquals("Renderer service delete in progress", result.getStatusMessage());