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;
11 import static org.mockito.Mockito.verify;
13 import java.lang.reflect.InvocationTargetException;
14 import java.lang.reflect.Method;
15 import java.util.Arrays;
16 import java.util.HashMap;
17 import java.util.List;
18 import java.util.Optional;
19 import java.util.concurrent.ExecutionException;
20 import java.util.concurrent.Future;
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.mockito.InjectMocks;
26 import org.mockito.Mock;
27 import org.mockito.Mockito;
28 import org.mockito.MockitoAnnotations;
29 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
30 import org.opendaylight.transportpce.common.OperationResult;
31 import org.opendaylight.transportpce.common.ResponseCodes;
32 import org.opendaylight.transportpce.pce.service.PathComputationService;
33 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
34 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
35 import org.opendaylight.transportpce.pce.utils.PceTestData;
36 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
37 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
38 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
39 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
40 import org.opendaylight.transportpce.servicehandler.ServiceInput;
41 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
42 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
43 import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
44 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
45 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
46 import org.opendaylight.transportpce.test.AbstractTest;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutputBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirectionBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirectionBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.Lgx;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
81 import org.opendaylight.yangtools.yang.common.RpcResult;
82 import org.slf4j.Logger;
83 import org.slf4j.LoggerFactory;
85 public class ServiceHandlerImplTest extends AbstractTest {
87 private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerImplTest.class);
89 private PathComputationService pathComputationService;
90 private RendererServiceOperations rendererServiceOperations;
91 private ServicehandlerImpl serviceHandler;
94 private ServiceDataStoreOperations serviceDataStoreOperationsMock;
97 private PCEServiceWrapper pceServiceWrapperMock;
100 private RendererServiceOperations rendererServiceOperationsMock;
103 private ComplianceCheckResult complianceCheckResultMock;
106 private Optional<Services> servicesOptionalMock;
109 private ServicehandlerImpl serviceHandlerImplMock;
112 public void setUp() {
113 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
114 this.rendererServiceOperations);
115 this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
116 MockitoAnnotations.initMocks(this);
119 public ServiceHandlerImplTest() throws Exception {
120 NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
121 this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
122 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
123 "topologyData/NW-simple-topology.xml");
124 this.rendererServiceOperations = new StubRendererServiceOperations();
128 public void testCreateServiceValid() throws ExecutionException, InterruptedException {
130 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
131 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
132 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
133 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
134 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
135 PceTestData.getPCE_simpletopology_test1_result((long) 5))
136 .setConfigurationResponseCommon(configurationResponseCommon).build();
138 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
139 .thenReturn(pathComputationRequestOutput);
140 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
141 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
142 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
143 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
144 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
145 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
146 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
148 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
149 .thenReturn(new ServiceImplementationRequestOutputBuilder()
150 .setConfigurationResponseCommon(configurationResponseCommon2).build());
151 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceInput.getServiceName(),
152 State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
154 Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
155 Assert.assertNotNull(output0);
156 Assert.assertTrue(output0.get().isSuccessful());
157 Assert.assertEquals(output0.get().getResult(),
158 ModelMappingUtils.createCreateServiceReply(serviceInput, ResponseCodes.FINAL_ACK_YES,
159 "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get().getResult());
160 Assert.assertEquals(0, output0.get().getErrors().size());
164 public void createTempServiceHandlerServiceCreateValid() throws ExecutionException, InterruptedException {
165 TempServiceCreateInput serviceInput = ServiceDataUtils.buildTempServiceCreateInput();
166 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
167 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
168 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
169 PathComputationRequestOutput pathComputationRequestOutput =
170 new PathComputationRequestOutputBuilder(PceTestData.getPCE_simpletopology_test1_result((long) 5))
171 .setConfigurationResponseCommon(configurationResponseCommon).build();
172 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
173 .thenReturn(pathComputationRequestOutput);
174 Mockito.when(this.serviceDataStoreOperationsMock.createTempService(any(TempServiceCreateInput.class),
175 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
176 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
177 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
178 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
179 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
180 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
182 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
183 .thenReturn(new ServiceImplementationRequestOutputBuilder()
184 .setConfigurationResponseCommon(configurationResponseCommon2).build());
185 Mockito.when(this.serviceDataStoreOperationsMock.modifyTempService(serviceInput.getCommonId(), State.InService,
186 State.InService)).thenReturn(OperationResult.ok("successful"));
187 Future<RpcResult<TempServiceCreateOutput>> output0 =
188 this.serviceHandlerImplMock.tempServiceCreate(serviceInput);
189 Assert.assertNotNull(output0);
190 Assert.assertTrue(output0.get().isSuccessful());
191 Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
192 ResponseCodes.FINAL_ACK_YES, "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get()
194 Assert.assertEquals(0, output0.get().getErrors().size());
198 public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
199 ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
200 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyServiceNameInput);
201 emptyServiceNameInput = builtInput.setServiceName("").build();
202 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
203 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
204 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
209 public void createServiceHandlerInvalidIfNameIsNull() throws ExecutionException, InterruptedException {
210 ServiceCreateInput nullServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
211 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(nullServiceNameInput);
212 nullServiceNameInput = builtInput.setServiceName(null).build();
213 Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
214 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
215 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
220 public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
221 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
222 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
223 emptyServiceNameInput = builtInput.setCommonId("").build();
224 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
225 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
226 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
231 public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
232 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
233 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
234 emptyServiceNameInput = builtInput.setCommonId(null).build();
235 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
236 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
237 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
242 public void createServiceHnadlerInvalidIfConTypeIsEmpty() throws ExecutionException, InterruptedException {
243 ServiceCreateInput emptyConTypeInput = ServiceDataUtils.buildServiceCreateInput();
244 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyConTypeInput);
245 emptyConTypeInput = builtInput.setConnectionType(null).build();
246 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyConTypeInput).get().getResult(),
247 ModelMappingUtils.createCreateServiceReply(emptyConTypeInput, ResponseCodes.FINAL_ACK_YES,
248 "Service ConnectionType is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
252 public void createServiceHandlerInvalidIfSdncRequestHeaderNull() throws ExecutionException, InterruptedException {
253 ServiceCreateInput emptySdncRequestHeader = ServiceDataUtils.buildServiceCreateInput();
254 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptySdncRequestHeader);
255 emptySdncRequestHeader = buildInput.setSdncRequestHeader(null).build();
256 ServiceCreateOutput result = this.serviceHandler.serviceCreate(emptySdncRequestHeader).get().getResult();
257 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
258 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
259 ResponseCodes.FINAL_ACK_YES);
263 public void createServiceHandlerInvalidIfRequestIdEmpty() throws ExecutionException, InterruptedException {
264 ServiceCreateInput emptyRequestId = ServiceDataUtils.buildServiceCreateInput();
265 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyRequestId);
266 emptyRequestId = buildInput
267 .setSdncRequestHeader(
268 new SdncRequestHeaderBuilder(emptyRequestId.getSdncRequestHeader()).setRequestId("").build())
270 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyRequestId).get().getResult(),
272 .createCreateServiceReply(emptyRequestId, ResponseCodes.FINAL_ACK_YES,
273 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
278 public void createServiceHandlerInvalidIfRequestIdNull() throws ExecutionException, InterruptedException {
279 ServiceCreateInput nullRequestId = ServiceDataUtils.buildServiceCreateInput();
280 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(nullRequestId);
281 nullRequestId = buildInput
282 .setSdncRequestHeader(
283 new SdncRequestHeaderBuilder(nullRequestId.getSdncRequestHeader()).setRequestId(null).build())
285 Assert.assertEquals(this.serviceHandler.serviceCreate(nullRequestId).get().getResult(),
287 .createCreateServiceReply(nullRequestId, ResponseCodes.FINAL_ACK_YES,
288 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
293 public void serviceHandlerInvalidServiceActionIsNull() throws ExecutionException, InterruptedException {
294 ServiceCreateInput emptyServiceAction = ServiceDataUtils.buildServiceCreateInput();
295 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyServiceAction);
296 emptyServiceAction = buildInput.setSdncRequestHeader(
297 new SdncRequestHeaderBuilder(emptyServiceAction.getSdncRequestHeader()).setRpcAction(null).build())
299 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceAction).get().getResult(),
301 .createCreateServiceReply(emptyServiceAction, ResponseCodes.FINAL_ACK_YES,
302 "Service sndc-request-header 'rpc-action' is not set ", ResponseCodes.RESPONSE_FAILED)
307 public void serviceHandlerInvalidServiceActionIsNotCreate() throws ExecutionException, InterruptedException {
308 ServiceCreateInput notCreateServiceAction = ServiceDataUtils.buildServiceCreateInput();
309 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notCreateServiceAction);
310 notCreateServiceAction = buildInput
311 .setSdncRequestHeader(new SdncRequestHeaderBuilder(notCreateServiceAction.getSdncRequestHeader())
312 .setRpcAction(RpcActions.ServiceFeasibilityCheck).build())
314 Assert.assertEquals(this.serviceHandler.serviceCreate(notCreateServiceAction).get().getResult(),
315 ModelMappingUtils.createCreateServiceReply(notCreateServiceAction, ResponseCodes.FINAL_ACK_YES,
316 "Service sdncRequestHeader rpc-action '"
317 + notCreateServiceAction.getSdncRequestHeader().getRpcAction() + "' not equal to '"
318 + RpcActions.ServiceCreate.name() + "'",
319 ResponseCodes.RESPONSE_FAILED).get().getResult());
323 public void createServiceHandlerNotValidServiceAEndIsNull() throws ExecutionException, InterruptedException {
324 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
325 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
326 notValidServiceAEnd = buildInput.setServiceAEnd(null).build();
327 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
328 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
329 "SERVICEAEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
333 public void createServiceHandlerNotValidServiceZEndIsNull() throws ExecutionException, InterruptedException {
334 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
335 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
336 notValidServiceAEnd = buildInput.setServiceZEnd(null).build();
337 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
338 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
339 "SERVICEZEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
343 public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
344 ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
345 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
346 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
347 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
349 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceAEnd).get().getResult(),
350 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
351 "Service " + ServiceEndpointType.SERVICEAEND + " rate is not set",
352 ResponseCodes.RESPONSE_FAILED).get().getResult());
356 public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
357 ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
358 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
359 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
360 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
362 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceZEnd).get().getResult(),
363 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
364 "Service " + ServiceEndpointType.SERVICEZEND + " rate is not set",
365 ResponseCodes.RESPONSE_FAILED).get().getResult());
369 public void createServiceHandlerNotValidServiceAEndClliIsNull()
370 throws ExecutionException, InterruptedException {
371 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
372 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
373 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setClli(null)
375 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
376 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
377 "Service" + ServiceEndpointType.SERVICEAEND + " clli format is not set",
378 ResponseCodes.RESPONSE_FAILED).get().getResult());
382 public void createServiceHandlerNotValidServiceZEndClliIsNull()
383 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
384 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
385 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
386 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setClli(null).build())
388 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceZEnd).get().getResult(),
389 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
390 "Service" + ServiceEndpointType.SERVICEZEND + " clli format is not set",
391 ResponseCodes.RESPONSE_FAILED).get().getResult());
395 public void createServiceHandlerNotValidServiceAEndAttributes()
396 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
397 HashMap<String, Object> notValidData = new HashMap<>();
398 notValidData.put("setServiceRate", 0L);
399 notValidData.put("setServiceFormat", null);
400 notValidData.put("setClli", "");
401 notValidData.put("setTxDirection", null);
402 notValidData.put("setRxDirection", null);
403 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
404 .ServiceAEndBuilder.class.getDeclaredMethods()) {
405 if (notValidData.containsKey(method.getName())) {
406 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
407 .buildServiceCreateInput());
408 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
409 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
410 method.invoke(serviceAEndBuilder, notValidData.get(method.getName()));
411 ServiceCreateOutput result = this.serviceHandler
412 .serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get().getResult();
413 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
414 ResponseCodes.FINAL_ACK_YES);
415 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
416 ResponseCodes.RESPONSE_FAILED);
422 public void createServiceHandlerNotValidServiceZEndAttributes()
423 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
424 HashMap<String, Object> notValidData = new HashMap<>();
425 notValidData.put("setServiceRate", 0L);
426 notValidData.put("setServiceFormat", null);
427 notValidData.put("setClli", "");
428 notValidData.put("setTxDirection", null);
429 notValidData.put("setRxDirection", null);
430 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
431 .ServiceZEndBuilder.class.getDeclaredMethods()) {
432 if (notValidData.containsKey(method.getName())) {
433 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
434 .buildServiceCreateInput());
435 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
436 .ServiceZEndBuilder serviceZEndBuilder = ServiceDataUtils.getServiceZEndBuild();
437 method.invoke(serviceZEndBuilder, notValidData.get(method.getName()));
438 ServiceCreateOutput result = this.serviceHandler
439 .serviceCreate(buildInput.setServiceZEnd(serviceZEndBuilder.build()).build()).get().getResult();
440 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
441 ResponseCodes.FINAL_ACK_YES);
442 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
443 ResponseCodes.RESPONSE_FAILED);
449 public void createServiceHandlerNotValidTxDirectionPort()
450 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
451 List<String> invalidData = Arrays.asList(null, "");
452 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
453 for (Method method : PortBuilder.class.getMethods()) {
454 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
455 for (Object data : invalidData) {
456 PortBuilder portBuilder = new PortBuilder(
457 serviceCreateInput.getServiceAEnd().getTxDirection().getPort());
458 method.invoke(portBuilder, data);
459 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(portBuilder.build(),
460 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
461 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
462 ResponseCodes.FINAL_ACK_YES);
463 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
464 ResponseCodes.RESPONSE_FAILED);
471 public void createServiceHandlerTxDirectionPortIsNull() throws ExecutionException, InterruptedException {
472 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(null,
473 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getLgx());
474 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
475 ResponseCodes.FINAL_ACK_YES);
476 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
480 public void createServiceHandlerNotValidTxDirectionLgx()
481 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
482 List<String> invalidData = Arrays.asList(null, "");
483 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
484 for (Method method : LgxBuilder.class.getMethods()) {
485 if (method.getName().startsWith("set")) {
486 for (Object data : invalidData) {
487 LgxBuilder lgxBuilder = new LgxBuilder(
488 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
489 method.invoke(lgxBuilder, data);
490 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
491 serviceCreateInput.getServiceAEnd().getTxDirection().getPort(), lgxBuilder.build());
492 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
493 ResponseCodes.FINAL_ACK_YES);
494 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
495 ResponseCodes.RESPONSE_FAILED);
502 public void createServiceHandlerTxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
503 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
504 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getPort(), null);
505 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
506 ResponseCodes.FINAL_ACK_YES);
507 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
510 private ServiceCreateOutput getTxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
511 throws InterruptedException, ExecutionException {
512 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
513 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
514 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
515 TxDirectionBuilder txDirectionBuilder = new TxDirectionBuilder(
516 serviceCreateInput.getServiceAEnd().getTxDirection());
517 txDirectionBuilder.setPort(port);
518 txDirectionBuilder.setLgx(lgx);
519 serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
520 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
521 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, 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();
593 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
594 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
595 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failed").build();
596 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
597 PceTestData.getPCE_simpletopology_test1_result((long) 5))
598 .setConfigurationResponseCommon(configurationResponseCommon).build();
599 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
600 .thenReturn(pathComputationRequestOutput);
601 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
602 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
603 ResponseCodes.FINAL_ACK_YES);
604 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
605 verify(this.pceServiceWrapperMock).performPCE(serviceCreateInput, true);
609 public void createServiceHandlerOperationResultNotPassed() throws ExecutionException, InterruptedException {
610 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
611 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
612 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
613 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
614 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
615 PceTestData.getPCE_simpletopology_test1_result((long) 5))
616 .setConfigurationResponseCommon(configurationResponseCommon).build();
617 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
618 .thenReturn(pathComputationRequestOutput);
619 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
620 any(PathComputationRequestOutput.class)))
621 .thenReturn(OperationResult.failed(
622 "Failed to create service " + serviceCreateInput.getServiceName() + " to Service List"));
623 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
624 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
625 ResponseCodes.FINAL_ACK_YES);
626 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
627 verify(this.serviceDataStoreOperationsMock).createService(any(ServiceCreateInput.class),
628 any(PathComputationRequestOutput.class));
632 public void createServiceHandlerOperationServicePathSaveResultNotPassed()
633 throws ExecutionException, InterruptedException {
634 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
635 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
636 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
637 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
638 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
639 PceTestData.getPCE_simpletopology_test1_result((long) 5))
640 .setConfigurationResponseCommon(configurationResponseCommon).build();
641 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
642 .thenReturn(pathComputationRequestOutput);
643 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
644 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
645 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
646 any(PathComputationRequestOutput.class)))
647 .thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
648 + " to ServicePath List"));
649 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
650 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
651 ResponseCodes.FINAL_ACK_YES);
652 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
653 verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceInput.class),
654 any(PathComputationRequestOutput.class));
658 public void createServiceHandlerModifyServicePassed() throws ExecutionException, InterruptedException {
659 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
660 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
661 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
662 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
663 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
664 PceTestData.getPCE_simpletopology_test1_result((long) 5))
665 .setConfigurationResponseCommon(configurationResponseCommon).build();
666 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
667 .thenReturn(pathComputationRequestOutput);
668 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
669 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
670 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
671 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
672 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
673 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
674 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
677 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
678 .thenReturn(new ServiceImplementationRequestOutputBuilder()
679 .setConfigurationResponseCommon(configurationResponseCommon2).build());
680 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
681 State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
682 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
683 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
684 ResponseCodes.FINAL_ACK_YES);
685 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
686 verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
691 public void createServiceHandlerModifyServiceNotPassed() throws ExecutionException, InterruptedException {
692 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
693 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
694 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
695 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
696 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
697 PceTestData.getPCE_simpletopology_test1_result((long) 5))
698 .setConfigurationResponseCommon(configurationResponseCommon).build();
699 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
700 .thenReturn(pathComputationRequestOutput);
701 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
702 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
703 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
704 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
705 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
706 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
707 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
710 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
711 .thenReturn(new ServiceImplementationRequestOutputBuilder()
712 .setConfigurationResponseCommon(configurationResponseCommon2).build());
713 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
714 State.InService, State.InService)).thenReturn(OperationResult.failed("failure"));
715 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
716 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
717 ResponseCodes.FINAL_ACK_YES);
718 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
719 verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
724 public void createServiceHandlerServiceImplementationNotPassed() throws ExecutionException, InterruptedException {
725 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
726 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
727 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
728 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
729 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
730 PceTestData.getPCE_simpletopology_test1_result((long) 5))
731 .setConfigurationResponseCommon(configurationResponseCommon).build();
732 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
733 .thenReturn(pathComputationRequestOutput);
734 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
735 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
736 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
737 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
738 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
739 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
740 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
743 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
744 .thenReturn(new ServiceImplementationRequestOutputBuilder()
745 .setConfigurationResponseCommon(configurationResponseCommon2).build());
746 Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
747 .thenReturn(OperationResult.ok("successful"));
748 Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
749 .thenReturn(OperationResult.ok("successful"));
750 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
751 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
752 ResponseCodes.FINAL_ACK_YES);
753 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
754 verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
755 verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
759 public void createServiceHandlerServiceImplementationNotPassed2() throws ExecutionException, InterruptedException {
760 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
761 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
762 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
763 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
764 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
765 PceTestData.getPCE_simpletopology_test1_result((long) 5))
766 .setConfigurationResponseCommon(configurationResponseCommon).build();
767 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
768 .thenReturn(pathComputationRequestOutput);
769 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
770 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
771 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
772 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
773 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
774 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
775 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
778 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
779 .thenReturn(new ServiceImplementationRequestOutputBuilder()
780 .setConfigurationResponseCommon(configurationResponseCommon2).build());
781 Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
782 .thenReturn(OperationResult.failed("successful"));
783 Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
784 .thenReturn(OperationResult.failed("successful"));
785 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
786 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
787 ResponseCodes.FINAL_ACK_YES);
788 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
789 verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
790 verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
793 private ServiceCreateOutput getRxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
794 throws InterruptedException, ExecutionException {
795 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
796 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
797 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
798 RxDirectionBuilder rxDirectionBuilder = new RxDirectionBuilder(
799 serviceCreateInput.getServiceAEnd().getRxDirection());
800 rxDirectionBuilder.setPort(port);
801 rxDirectionBuilder.setLgx(lgx);
802 serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
803 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
804 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
805 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
810 public void deleteServiceInvalidIfServiceNameIsEmpty() throws ExecutionException, InterruptedException {
812 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
813 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
814 serviceDeleteInput = builder
815 .setServiceDeleteReqInfo(
816 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName("").build())
818 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
819 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
820 ResponseCodes.FINAL_ACK_YES);
821 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
825 public void deleteServiceInvalidIfServiceNameIsNull() throws ExecutionException, InterruptedException {
827 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
828 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
829 serviceDeleteInput = builder
830 .setServiceDeleteReqInfo(
831 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName(null).build())
833 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
834 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
835 ResponseCodes.FINAL_ACK_YES);
836 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
840 public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
841 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
842 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
843 serviceDeleteInput = builder.setCommonId("").build();
844 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
845 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
846 ResponseCodes.FINAL_ACK_YES);
847 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
851 public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
852 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
853 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
854 serviceDeleteInput = builder.setCommonId(null).build();
855 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
856 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
857 ResponseCodes.FINAL_ACK_YES);
858 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
862 public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
863 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
864 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
865 serviceDeleteInput = builder.setSdncRequestHeader(null).build();
866 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
867 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
868 ResponseCodes.FINAL_ACK_YES);
869 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
873 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsNull()
874 throws ExecutionException, InterruptedException {
876 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
877 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
878 serviceDeleteInput = builder
879 .setSdncRequestHeader(
880 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId(null).build())
882 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
883 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
884 ResponseCodes.FINAL_ACK_YES);
885 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
889 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsEmpty()
890 throws ExecutionException, InterruptedException {
892 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
893 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
894 serviceDeleteInput = builder.setSdncRequestHeader(
895 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId("").build()).build();
896 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
897 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
898 ResponseCodes.FINAL_ACK_YES);
899 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
903 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNull()
904 throws ExecutionException, InterruptedException {
906 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
907 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
908 serviceDeleteInput = builder
909 .setSdncRequestHeader(
910 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRpcAction(null).build())
912 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
913 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
914 ResponseCodes.FINAL_ACK_YES);
915 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
919 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNotDelete()
920 throws ExecutionException, InterruptedException {
922 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
923 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
924 serviceDeleteInput = builder.setSdncRequestHeader(new SdncRequestHeaderBuilder(builder.getSdncRequestHeader())
925 .setRpcAction(RpcActions.ServiceCreate).build()).build();
926 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
927 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
928 ResponseCodes.FINAL_ACK_YES);
929 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
933 public void deleteServiceIfServiceHandlerCompliancyCheckNotPassed()
934 throws ExecutionException, InterruptedException {
936 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
938 Mockito.when(this.complianceCheckResultMock.hasPassed()).thenReturn(false);
940 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
941 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
942 ResponseCodes.FINAL_ACK_YES);
943 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
947 public void deleteServiceNotPresent() throws ExecutionException, InterruptedException {
949 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(ServiceDataUtils.buildServiceDeleteInput()).get()
951 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
952 ResponseCodes.FINAL_ACK_YES);
953 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
957 public void deleteServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
959 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
960 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
961 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
962 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
963 ResponseCodes.FINAL_ACK_YES);
964 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
968 public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
969 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
970 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
971 TempServiceDeleteOutput result =
972 this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
973 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
974 ResponseCodes.FINAL_ACK_YES);
975 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
979 public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
981 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
982 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
983 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
984 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
985 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
986 new ServiceInput(serviceDeleteInput));
987 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
988 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
989 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("success").build();
990 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
991 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
992 .setConfigurationResponseCommon(configurationResponseCommon).build();
993 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
994 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
995 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
996 ResponseCodes.FINAL_ACK_YES);
997 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
1001 public void deleteServicePathNotPassed() throws ExecutionException, InterruptedException {
1003 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1004 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
1005 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
1006 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1007 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1008 new ServiceInput(serviceDeleteInput));
1009 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1010 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1011 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1012 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1013 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
1014 .setConfigurationResponseCommon(configurationResponseCommon).build();
1015 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1016 Mockito.when(this.serviceDataStoreOperationsMock
1017 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1018 .thenReturn(OperationResult.failed("failed"));
1019 Mockito.when(this.serviceDataStoreOperationsMock
1020 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1021 .thenReturn(OperationResult.failed("failed"));
1022 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
1023 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1024 ResponseCodes.FINAL_ACK_YES);
1025 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1029 public void deleteServiceOperationNotPassed() throws ExecutionException, InterruptedException {
1031 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1032 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
1033 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
1034 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1035 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1036 new ServiceInput(serviceDeleteInput));
1037 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1038 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1039 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1040 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1041 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
1042 .setConfigurationResponseCommon(configurationResponseCommon).build();
1043 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1044 Mockito.when(this.serviceDataStoreOperationsMock
1045 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1046 .thenReturn(OperationResult.ok("success"));
1047 Mockito.when(this.serviceDataStoreOperationsMock
1048 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1049 .thenReturn(OperationResult.ok("success"));
1050 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
1051 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1052 ResponseCodes.FINAL_ACK_YES);
1053 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1057 public void deleteServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
1059 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1060 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
1061 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
1062 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1063 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1064 new ServiceInput(serviceDeleteInput));
1065 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1066 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1067 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1068 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1069 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
1070 .rev171017.ServiceDeleteOutputBuilder()
1071 .setConfigurationResponseCommon(configurationResponseCommon).build();
1072 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1073 Mockito.when(this.serviceDataStoreOperationsMock
1074 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1075 .thenReturn(OperationResult.ok("success"));
1076 Mockito.when(this.serviceDataStoreOperationsMock
1077 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1078 .thenReturn(OperationResult.ok("success"));
1079 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
1080 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1081 ResponseCodes.FINAL_ACK_YES);
1082 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1086 public void deleteTempServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
1088 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
1089 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
1090 .Services> service = Optional.of(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
1091 .temp.service.list.ServicesBuilder().setCommonId("service 1").build());
1092 Mockito.when(this.serviceDataStoreOperationsMock.getTempService("service 1")).thenReturn(service);
1093 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1094 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1095 new ServiceInput(serviceDeleteInput));
1096 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1097 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1098 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1099 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1100 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
1101 .rev171017.ServiceDeleteOutputBuilder()
1102 .setConfigurationResponseCommon(configurationResponseCommon).build();
1103 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1104 Mockito.when(this.serviceDataStoreOperationsMock
1105 .deleteServicePath(serviceDeleteInput.getCommonId()))
1106 .thenReturn(OperationResult.ok("success"));
1107 Mockito.when(this.serviceDataStoreOperationsMock
1108 .deleteTempService(serviceDeleteInput.getCommonId()))
1109 .thenReturn(OperationResult.ok("success"));
1110 TempServiceDeleteOutput result = this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get()
1112 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1113 ResponseCodes.FINAL_ACK_YES);
1114 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1118 public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
1120 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
1121 ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
1122 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
1123 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
1128 public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
1130 ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
1131 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1132 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
1134 /** Mock RPC service-delete. */
1135 Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null);
1136 Optional<Services> service = Optional.of(serviceMock);
1137 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
1138 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1139 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
1140 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1141 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1142 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1143 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1144 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
1145 .rev171017.ServiceDeleteOutputBuilder()
1146 .setConfigurationResponseCommon(configurationResponseCommon).build();
1147 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1148 Mockito.when(this.serviceDataStoreOperationsMock
1149 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1150 .thenReturn(OperationResult.ok("success"));
1151 Mockito.when(this.serviceDataStoreOperationsMock
1152 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1153 .thenReturn(OperationResult.ok("success"));
1155 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
1156 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1157 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1158 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
1159 PceTestData.getPCE_simpletopology_test1_result((long) 5))
1160 .setConfigurationResponseCommon(configurationResponseCommon2).build();
1162 /** Mock RPC service-create. */
1163 Mockito.when(this.pceServiceWrapperMock.performPCE(any(ServiceCreateInput.class), any(Boolean.class)))
1164 .thenReturn(pathComputationRequestOutput);
1165 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
1166 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
1167 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
1168 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
1169 ConfigurationResponseCommon configurationResponseCommon3 = new ConfigurationResponseCommonBuilder()
1170 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1171 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
1173 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
1174 .thenReturn(new ServiceImplementationRequestOutputBuilder()
1175 .setConfigurationResponseCommon(configurationResponseCommon3).build());
1176 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(any(String.class), any(State.class),
1177 any(State.class))).thenReturn(OperationResult.ok("successful"));
1179 ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
1180 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
1181 result.getStatus());
1182 Assert.assertEquals("Service reroute successfully !", result.getStatusMessage());