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.NetworkModelWavelengthService;
38 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
39 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
40 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
41 import org.opendaylight.transportpce.servicehandler.ServiceInput;
42 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
43 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
44 import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
45 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
46 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
47 import org.opendaylight.transportpce.test.AbstractTest;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutput;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestOutputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirectionBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirectionBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.Lgx;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
82 import org.opendaylight.yangtools.yang.common.RpcResult;
83 import org.slf4j.Logger;
84 import org.slf4j.LoggerFactory;
86 public class ServiceHandlerImplTest extends AbstractTest {
88 private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerImplTest.class);
90 private PathComputationService pathComputationService;
91 private RendererServiceOperations rendererServiceOperations;
92 private NetworkModelWavelengthService networkModelWavelengthService;
93 private ServicehandlerImpl serviceHandler;
96 private ServiceDataStoreOperations serviceDataStoreOperationsMock;
99 private PCEServiceWrapper pceServiceWrapperMock;
102 private RendererServiceOperations rendererServiceOperationsMock;
105 private ComplianceCheckResult complianceCheckResultMock;
108 private Optional<Services> servicesOptionalMock;
111 private ServicehandlerImpl serviceHandlerImplMock;
114 public void setUp() {
115 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
116 this.rendererServiceOperations, this.networkModelWavelengthService);
117 this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
118 MockitoAnnotations.initMocks(this);
121 public ServiceHandlerImplTest() throws Exception {
122 NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
123 this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
124 PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
125 "topologyData/NW-simple-topology.xml");
126 this.rendererServiceOperations =
127 new StubRendererServiceOperations(this.networkModelWavelengthService, getDataBroker());
131 public void testCreateServiceValid() throws ExecutionException, InterruptedException {
133 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
134 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
135 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
136 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
137 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
138 PceTestData.getPCE_simpletopology_test1_result((long) 5))
139 .setConfigurationResponseCommon(configurationResponseCommon).build();
141 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
142 .thenReturn(pathComputationRequestOutput);
143 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
144 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
145 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
146 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
147 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
148 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
149 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
151 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
152 .thenReturn(new ServiceImplementationRequestOutputBuilder()
153 .setConfigurationResponseCommon(configurationResponseCommon2).build());
154 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceInput.getServiceName(),
155 State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
157 Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
158 Assert.assertNotNull(output0);
159 Assert.assertTrue(output0.get().isSuccessful());
160 Assert.assertEquals(output0.get().getResult(),
161 ModelMappingUtils.createCreateServiceReply(serviceInput, ResponseCodes.FINAL_ACK_YES,
162 "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get().getResult());
163 Assert.assertEquals(0, output0.get().getErrors().size());
167 public void createTempServiceHandlerServiceCreateValid() throws ExecutionException, InterruptedException {
168 TempServiceCreateInput serviceInput = ServiceDataUtils.buildTempServiceCreateInput();
169 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
170 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
171 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
172 PathComputationRequestOutput pathComputationRequestOutput =
173 new PathComputationRequestOutputBuilder(PceTestData.getPCE_simpletopology_test1_result((long) 5))
174 .setConfigurationResponseCommon(configurationResponseCommon).build();
175 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
176 .thenReturn(pathComputationRequestOutput);
177 Mockito.when(this.serviceDataStoreOperationsMock.createTempService(any(TempServiceCreateInput.class),
178 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
179 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
180 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
181 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
182 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
183 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
185 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
186 .thenReturn(new ServiceImplementationRequestOutputBuilder()
187 .setConfigurationResponseCommon(configurationResponseCommon2).build());
188 Mockito.when(this.serviceDataStoreOperationsMock.modifyTempService(serviceInput.getCommonId(), State.InService,
189 State.InService)).thenReturn(OperationResult.ok("successful"));
190 Future<RpcResult<TempServiceCreateOutput>> output0 =
191 this.serviceHandlerImplMock.tempServiceCreate(serviceInput);
192 Assert.assertNotNull(output0);
193 Assert.assertTrue(output0.get().isSuccessful());
194 Assert.assertEquals(output0.get().getResult(), ModelMappingUtils.createCreateServiceReply(serviceInput,
195 ResponseCodes.FINAL_ACK_YES, "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get()
197 Assert.assertEquals(0, output0.get().getErrors().size());
201 public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
202 ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
203 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyServiceNameInput);
204 emptyServiceNameInput = builtInput.setServiceName("").build();
205 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
206 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
207 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
212 public void createServiceHandlerInvalidIfNameIsNull() throws ExecutionException, InterruptedException {
213 ServiceCreateInput nullServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
214 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(nullServiceNameInput);
215 nullServiceNameInput = builtInput.setServiceName(null).build();
216 Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
217 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
218 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
223 public void createTempServiceHandlerInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
224 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
225 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
226 emptyServiceNameInput = builtInput.setCommonId("").build();
227 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
228 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
229 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED).get()
234 public void createTempServiceHandlerInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
235 TempServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildTempServiceCreateInput();
236 TempServiceCreateInputBuilder builtInput = new TempServiceCreateInputBuilder(emptyServiceNameInput);
237 emptyServiceNameInput = builtInput.setCommonId(null).build();
238 Assert.assertEquals(this.serviceHandler.tempServiceCreate(emptyServiceNameInput).get().getResult(),
239 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
240 "Service Name (common-id for Temp service) is not set", ResponseCodes.RESPONSE_FAILED)
245 public void createServiceHnadlerInvalidIfConTypeIsEmpty() throws ExecutionException, InterruptedException {
246 ServiceCreateInput emptyConTypeInput = ServiceDataUtils.buildServiceCreateInput();
247 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyConTypeInput);
248 emptyConTypeInput = builtInput.setConnectionType(null).build();
249 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyConTypeInput).get().getResult(),
250 ModelMappingUtils.createCreateServiceReply(emptyConTypeInput, ResponseCodes.FINAL_ACK_YES,
251 "Service ConnectionType is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
255 public void createServiceHandlerInvalidIfSdncRequestHeaderNull() throws ExecutionException, InterruptedException {
256 ServiceCreateInput emptySdncRequestHeader = ServiceDataUtils.buildServiceCreateInput();
257 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptySdncRequestHeader);
258 emptySdncRequestHeader = buildInput.setSdncRequestHeader(null).build();
259 ServiceCreateOutput result = this.serviceHandler.serviceCreate(emptySdncRequestHeader).get().getResult();
260 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
261 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
262 ResponseCodes.FINAL_ACK_YES);
266 public void createServiceHandlerInvalidIfRequestIdEmpty() throws ExecutionException, InterruptedException {
267 ServiceCreateInput emptyRequestId = ServiceDataUtils.buildServiceCreateInput();
268 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyRequestId);
269 emptyRequestId = buildInput
270 .setSdncRequestHeader(
271 new SdncRequestHeaderBuilder(emptyRequestId.getSdncRequestHeader()).setRequestId("").build())
273 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyRequestId).get().getResult(),
275 .createCreateServiceReply(emptyRequestId, ResponseCodes.FINAL_ACK_YES,
276 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
281 public void createServiceHandlerInvalidIfRequestIdNull() throws ExecutionException, InterruptedException {
282 ServiceCreateInput nullRequestId = ServiceDataUtils.buildServiceCreateInput();
283 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(nullRequestId);
284 nullRequestId = buildInput
285 .setSdncRequestHeader(
286 new SdncRequestHeaderBuilder(nullRequestId.getSdncRequestHeader()).setRequestId(null).build())
288 Assert.assertEquals(this.serviceHandler.serviceCreate(nullRequestId).get().getResult(),
290 .createCreateServiceReply(nullRequestId, ResponseCodes.FINAL_ACK_YES,
291 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
296 public void serviceHandlerInvalidServiceActionIsNull() throws ExecutionException, InterruptedException {
297 ServiceCreateInput emptyServiceAction = ServiceDataUtils.buildServiceCreateInput();
298 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyServiceAction);
299 emptyServiceAction = buildInput.setSdncRequestHeader(
300 new SdncRequestHeaderBuilder(emptyServiceAction.getSdncRequestHeader()).setRpcAction(null).build())
302 Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceAction).get().getResult(),
304 .createCreateServiceReply(emptyServiceAction, ResponseCodes.FINAL_ACK_YES,
305 "Service sndc-request-header 'rpc-action' is not set ", ResponseCodes.RESPONSE_FAILED)
310 public void serviceHandlerInvalidServiceActionIsNotCreate() throws ExecutionException, InterruptedException {
311 ServiceCreateInput notCreateServiceAction = ServiceDataUtils.buildServiceCreateInput();
312 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notCreateServiceAction);
313 notCreateServiceAction = buildInput
314 .setSdncRequestHeader(new SdncRequestHeaderBuilder(notCreateServiceAction.getSdncRequestHeader())
315 .setRpcAction(RpcActions.ServiceFeasibilityCheck).build())
317 Assert.assertEquals(this.serviceHandler.serviceCreate(notCreateServiceAction).get().getResult(),
318 ModelMappingUtils.createCreateServiceReply(notCreateServiceAction, ResponseCodes.FINAL_ACK_YES,
319 "Service sdncRequestHeader rpc-action '"
320 + notCreateServiceAction.getSdncRequestHeader().getRpcAction() + "' not equal to '"
321 + RpcActions.ServiceCreate.name() + "'",
322 ResponseCodes.RESPONSE_FAILED).get().getResult());
326 public void createServiceHandlerNotValidServiceAEndIsNull() throws ExecutionException, InterruptedException {
327 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
328 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
329 notValidServiceAEnd = buildInput.setServiceAEnd(null).build();
330 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
331 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
332 "SERVICEAEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
336 public void createServiceHandlerNotValidServiceZEndIsNull() throws ExecutionException, InterruptedException {
337 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
338 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
339 notValidServiceAEnd = buildInput.setServiceZEnd(null).build();
340 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
341 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
342 "SERVICEZEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
346 public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
347 ServicehandlerImpl servicehandler =
348 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
349 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
350 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
351 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
353 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceAEnd).get().getResult(),
354 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
355 "Service " + ServiceEndpointType.SERVICEAEND + " rate is not set",
356 ResponseCodes.RESPONSE_FAILED).get().getResult());
360 public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
361 ServicehandlerImpl servicehandler =
362 new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
363 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
364 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
365 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
367 Assert.assertEquals(servicehandler.serviceCreate(notValidServiceZEnd).get().getResult(),
368 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
369 "Service " + ServiceEndpointType.SERVICEZEND + " rate is not set",
370 ResponseCodes.RESPONSE_FAILED).get().getResult());
374 public void createServiceHandlerNotValidServiceAEndClliIsNull()
375 throws ExecutionException, InterruptedException {
376 ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
377 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
378 notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setClli(null)
380 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
381 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
382 "Service" + ServiceEndpointType.SERVICEAEND + " clli format is not set",
383 ResponseCodes.RESPONSE_FAILED).get().getResult());
387 public void createServiceHandlerNotValidServiceZEndClliIsNull()
388 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
389 ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
390 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
391 notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setClli(null).build())
393 Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceZEnd).get().getResult(),
394 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
395 "Service" + ServiceEndpointType.SERVICEZEND + " clli format is not set",
396 ResponseCodes.RESPONSE_FAILED).get().getResult());
400 public void createServiceHandlerNotValidServiceAEndAttributes()
401 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
402 HashMap<String, Object> notValidData = new HashMap<>();
403 notValidData.put("setServiceRate", 0L);
404 notValidData.put("setServiceFormat", null);
405 notValidData.put("setClli", "");
406 notValidData.put("setTxDirection", null);
407 notValidData.put("setRxDirection", null);
408 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
409 .ServiceAEndBuilder.class.getDeclaredMethods()) {
410 if (notValidData.containsKey(method.getName())) {
411 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
412 .buildServiceCreateInput());
413 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
414 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
415 method.invoke(serviceAEndBuilder, notValidData.get(method.getName()));
416 ServiceCreateOutput result = this.serviceHandler
417 .serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get().getResult();
418 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
419 ResponseCodes.FINAL_ACK_YES);
420 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
421 ResponseCodes.RESPONSE_FAILED);
427 public void createServiceHandlerNotValidServiceZEndAttributes()
428 throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
429 HashMap<String, Object> notValidData = new HashMap<>();
430 notValidData.put("setServiceRate", 0L);
431 notValidData.put("setServiceFormat", null);
432 notValidData.put("setClli", "");
433 notValidData.put("setTxDirection", null);
434 notValidData.put("setRxDirection", null);
435 for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
436 .ServiceZEndBuilder.class.getDeclaredMethods()) {
437 if (notValidData.containsKey(method.getName())) {
438 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
439 .buildServiceCreateInput());
440 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
441 .ServiceZEndBuilder serviceZEndBuilder = ServiceDataUtils.getServiceZEndBuild();
442 method.invoke(serviceZEndBuilder, notValidData.get(method.getName()));
443 ServiceCreateOutput result = this.serviceHandler
444 .serviceCreate(buildInput.setServiceZEnd(serviceZEndBuilder.build()).build()).get().getResult();
445 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
446 ResponseCodes.FINAL_ACK_YES);
447 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
448 ResponseCodes.RESPONSE_FAILED);
454 public void createServiceHandlerNotValidTxDirectionPort()
455 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
456 List<String> invalidData = Arrays.asList(null, "");
457 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
458 for (Method method : PortBuilder.class.getMethods()) {
459 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
460 for (Object data : invalidData) {
461 PortBuilder portBuilder = new PortBuilder(
462 serviceCreateInput.getServiceAEnd().getTxDirection().getPort());
463 method.invoke(portBuilder, data);
464 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(portBuilder.build(),
465 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
466 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
467 ResponseCodes.FINAL_ACK_YES);
468 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
469 ResponseCodes.RESPONSE_FAILED);
476 public void createServiceHandlerTxDirectionPortIsNull() throws ExecutionException, InterruptedException {
477 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(null,
478 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getLgx());
479 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
480 ResponseCodes.FINAL_ACK_YES);
481 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
485 public void createServiceHandlerNotValidTxDirectionLgx()
486 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
487 List<String> invalidData = Arrays.asList(null, "");
488 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
489 for (Method method : LgxBuilder.class.getMethods()) {
490 if (method.getName().startsWith("set")) {
491 for (Object data : invalidData) {
492 LgxBuilder lgxBuilder = new LgxBuilder(
493 serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
494 method.invoke(lgxBuilder, data);
495 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
496 serviceCreateInput.getServiceAEnd().getTxDirection().getPort(), lgxBuilder.build());
497 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
498 ResponseCodes.FINAL_ACK_YES);
499 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
500 ResponseCodes.RESPONSE_FAILED);
507 public void createServiceHandlerTxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
508 ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
509 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getPort(), null);
510 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
511 ResponseCodes.FINAL_ACK_YES);
512 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
515 private ServiceCreateOutput getTxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
516 throws InterruptedException, ExecutionException {
517 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
518 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
519 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
520 TxDirectionBuilder txDirectionBuilder = new TxDirectionBuilder(
521 serviceCreateInput.getServiceAEnd().getTxDirection());
522 txDirectionBuilder.setPort(port);
523 txDirectionBuilder.setLgx(lgx);
524 serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
525 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
526 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
527 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
532 public void createServiceHandlerNotValidRxDirectionPort()
533 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
534 List<String> invalidData = Arrays.asList(null, "");
535 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
536 for (Method method : PortBuilder.class.getMethods()) {
537 if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
538 for (Object data : invalidData) {
539 PortBuilder portBuilder = new PortBuilder(
540 serviceCreateInput.getServiceAEnd().getRxDirection().getPort());
541 method.invoke(portBuilder, data);
542 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(portBuilder.build(),
543 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
544 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
545 ResponseCodes.FINAL_ACK_YES);
546 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
547 ResponseCodes.RESPONSE_FAILED);
554 public void createServiceHandlerRxDirectionPortIsNull()
555 throws ExecutionException, InterruptedException {
556 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(null,
557 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getLgx());
558 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
559 ResponseCodes.FINAL_ACK_YES);
560 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
564 public void createServiceHandlerNotValidRxDirectionLgx()
565 throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
566 List<String> invalidData = Arrays.asList(null, "");
567 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
568 for (Method method : LgxBuilder.class.getMethods()) {
569 if (method.getName().startsWith("set")) {
570 for (Object data : invalidData) {
571 LgxBuilder lgxBuilder = new LgxBuilder(
572 serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
573 method.invoke(lgxBuilder, data);
574 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
575 serviceCreateInput.getServiceAEnd().getRxDirection().getPort(), lgxBuilder.build());
576 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
577 ResponseCodes.FINAL_ACK_YES);
578 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
579 ResponseCodes.RESPONSE_FAILED);
586 public void createServiceHandlerRxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
587 ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
588 ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getPort(), null);
589 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
590 ResponseCodes.FINAL_ACK_YES);
591 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
595 public void createServiceHandlerResponseCodesNotPassed() throws ExecutionException, InterruptedException {
596 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
598 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
599 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
600 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failed").build();
601 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
602 PceTestData.getPCE_simpletopology_test1_result((long) 5))
603 .setConfigurationResponseCommon(configurationResponseCommon).build();
604 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
605 .thenReturn(pathComputationRequestOutput);
606 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
607 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
608 ResponseCodes.FINAL_ACK_YES);
609 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
610 verify(this.pceServiceWrapperMock).performPCE(serviceCreateInput, true);
614 public void createServiceHandlerOperationResultNotPassed() throws ExecutionException, InterruptedException {
615 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
616 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
617 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
618 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
619 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
620 PceTestData.getPCE_simpletopology_test1_result((long) 5))
621 .setConfigurationResponseCommon(configurationResponseCommon).build();
622 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
623 .thenReturn(pathComputationRequestOutput);
624 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
625 any(PathComputationRequestOutput.class)))
626 .thenReturn(OperationResult.failed(
627 "Failed to create service " + serviceCreateInput.getServiceName() + " to Service List"));
628 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
629 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
630 ResponseCodes.FINAL_ACK_YES);
631 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
632 verify(this.serviceDataStoreOperationsMock).createService(any(ServiceCreateInput.class),
633 any(PathComputationRequestOutput.class));
637 public void createServiceHandlerOperationServicePathSaveResultNotPassed()
638 throws ExecutionException, InterruptedException {
639 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
640 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
641 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
642 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
643 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
644 PceTestData.getPCE_simpletopology_test1_result((long) 5))
645 .setConfigurationResponseCommon(configurationResponseCommon).build();
646 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
647 .thenReturn(pathComputationRequestOutput);
648 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
649 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
650 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
651 any(PathComputationRequestOutput.class)))
652 .thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
653 + " to ServicePath List"));
654 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
655 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
656 ResponseCodes.FINAL_ACK_YES);
657 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
658 verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceInput.class),
659 any(PathComputationRequestOutput.class));
663 public void createServiceHandlerModifyServicePassed() throws ExecutionException, InterruptedException {
664 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
665 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
666 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
667 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
668 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
669 PceTestData.getPCE_simpletopology_test1_result((long) 5))
670 .setConfigurationResponseCommon(configurationResponseCommon).build();
671 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
672 .thenReturn(pathComputationRequestOutput);
673 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
674 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
675 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
676 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
677 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
678 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
679 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
682 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
683 .thenReturn(new ServiceImplementationRequestOutputBuilder()
684 .setConfigurationResponseCommon(configurationResponseCommon2).build());
685 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
686 State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
687 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
688 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
689 ResponseCodes.FINAL_ACK_YES);
690 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
691 verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
696 public void createServiceHandlerModifyServiceNotPassed() throws ExecutionException, InterruptedException {
697 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
698 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
699 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
700 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
701 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
702 PceTestData.getPCE_simpletopology_test1_result((long) 5))
703 .setConfigurationResponseCommon(configurationResponseCommon).build();
704 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
705 .thenReturn(pathComputationRequestOutput);
706 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
707 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
708 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
709 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
710 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
711 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
712 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
715 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
716 .thenReturn(new ServiceImplementationRequestOutputBuilder()
717 .setConfigurationResponseCommon(configurationResponseCommon2).build());
718 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
719 State.InService, State.InService)).thenReturn(OperationResult.failed("failure"));
720 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
721 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
722 ResponseCodes.FINAL_ACK_YES);
723 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
724 verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
729 public void createServiceHandlerServiceImplementationNotPassed() throws ExecutionException, InterruptedException {
730 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
731 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
732 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
733 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
734 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
735 PceTestData.getPCE_simpletopology_test1_result((long) 5))
736 .setConfigurationResponseCommon(configurationResponseCommon).build();
737 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
738 .thenReturn(pathComputationRequestOutput);
739 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
740 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
741 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
742 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
743 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
744 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
745 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
748 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
749 .thenReturn(new ServiceImplementationRequestOutputBuilder()
750 .setConfigurationResponseCommon(configurationResponseCommon2).build());
751 Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
752 .thenReturn(OperationResult.ok("successful"));
753 Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
754 .thenReturn(OperationResult.ok("successful"));
755 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
756 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
757 ResponseCodes.FINAL_ACK_YES);
758 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
759 verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
760 verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
764 public void createServiceHandlerServiceImplementationNotPassed2() throws ExecutionException, InterruptedException {
765 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
766 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
767 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
768 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
769 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
770 PceTestData.getPCE_simpletopology_test1_result((long) 5))
771 .setConfigurationResponseCommon(configurationResponseCommon).build();
772 Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
773 .thenReturn(pathComputationRequestOutput);
774 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
775 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
776 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
777 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
778 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
779 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
780 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
783 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
784 .thenReturn(new ServiceImplementationRequestOutputBuilder()
785 .setConfigurationResponseCommon(configurationResponseCommon2).build());
786 Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
787 .thenReturn(OperationResult.failed("successful"));
788 Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
789 .thenReturn(OperationResult.failed("successful"));
790 ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
791 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
792 ResponseCodes.FINAL_ACK_YES);
793 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
794 verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
795 verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
798 private ServiceCreateOutput getRxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
799 throws InterruptedException, ExecutionException {
800 ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
801 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
802 .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
803 RxDirectionBuilder rxDirectionBuilder = new RxDirectionBuilder(
804 serviceCreateInput.getServiceAEnd().getRxDirection());
805 rxDirectionBuilder.setPort(port);
806 rxDirectionBuilder.setLgx(lgx);
807 serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
808 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
809 this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null, null);
810 return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
815 public void deleteServiceInvalidIfServiceNameIsEmpty() throws ExecutionException, InterruptedException {
817 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
818 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
819 serviceDeleteInput = builder
820 .setServiceDeleteReqInfo(
821 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName("").build())
823 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
824 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
825 ResponseCodes.FINAL_ACK_YES);
826 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
830 public void deleteServiceInvalidIfServiceNameIsNull() throws ExecutionException, InterruptedException {
832 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
833 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
834 serviceDeleteInput = builder
835 .setServiceDeleteReqInfo(
836 new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName(null).build())
838 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
839 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
840 ResponseCodes.FINAL_ACK_YES);
841 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
845 public void deleteTempServiceInvalidIfCommonIdIsEmpty() throws ExecutionException, InterruptedException {
846 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
847 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
848 serviceDeleteInput = builder.setCommonId("").build();
849 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
850 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
851 ResponseCodes.FINAL_ACK_YES);
852 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
856 public void deleteTempServiceInvalidIfCommonIdIsNull() throws ExecutionException, InterruptedException {
857 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
858 TempServiceDeleteInputBuilder builder = new TempServiceDeleteInputBuilder(serviceDeleteInput);
859 serviceDeleteInput = builder.setCommonId(null).build();
860 TempServiceDeleteOutput result = this.serviceHandler.tempServiceDelete(serviceDeleteInput).get().getResult();
861 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
862 ResponseCodes.FINAL_ACK_YES);
863 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
867 public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
868 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
869 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
870 serviceDeleteInput = builder.setSdncRequestHeader(null).build();
871 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
872 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
873 ResponseCodes.FINAL_ACK_YES);
874 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
878 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsNull()
879 throws ExecutionException, InterruptedException {
881 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
882 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
883 serviceDeleteInput = builder
884 .setSdncRequestHeader(
885 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId(null).build())
887 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
888 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
889 ResponseCodes.FINAL_ACK_YES);
890 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
894 public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsEmpty()
895 throws ExecutionException, InterruptedException {
897 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
898 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
899 serviceDeleteInput = builder.setSdncRequestHeader(
900 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId("").build()).build();
901 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
902 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
903 ResponseCodes.FINAL_ACK_YES);
904 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
908 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNull()
909 throws ExecutionException, InterruptedException {
911 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
912 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
913 serviceDeleteInput = builder
914 .setSdncRequestHeader(
915 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRpcAction(null).build())
917 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
918 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
919 ResponseCodes.FINAL_ACK_YES);
920 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
924 public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNotDelete()
925 throws ExecutionException, InterruptedException {
927 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
928 ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
929 serviceDeleteInput = builder.setSdncRequestHeader(new SdncRequestHeaderBuilder(builder.getSdncRequestHeader())
930 .setRpcAction(RpcActions.ServiceCreate).build()).build();
931 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
932 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
933 ResponseCodes.FINAL_ACK_YES);
934 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
938 public void deleteServiceIfServiceHandlerCompliancyCheckNotPassed()
939 throws ExecutionException, InterruptedException {
941 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
943 Mockito.when(this.complianceCheckResultMock.hasPassed()).thenReturn(false);
945 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
946 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
947 ResponseCodes.FINAL_ACK_YES);
948 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
952 public void deleteServiceNotPresent() throws ExecutionException, InterruptedException {
954 ServiceDeleteOutput result = this.serviceHandler.serviceDelete(ServiceDataUtils.buildServiceDeleteInput()).get()
956 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
957 ResponseCodes.FINAL_ACK_YES);
958 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
962 public void deleteServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
964 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
965 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
966 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
967 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
968 ResponseCodes.FINAL_ACK_YES);
969 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
973 public void deleteTempServiceIfTempServiceNotPresent() throws ExecutionException, InterruptedException {
974 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
975 Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
976 TempServiceDeleteOutput result =
977 this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get().getResult();
978 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
979 ResponseCodes.FINAL_ACK_YES);
980 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
984 public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
986 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
987 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
988 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
989 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
990 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
991 new ServiceInput(serviceDeleteInput));
992 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
993 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
994 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("success").build();
995 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
996 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
997 .setConfigurationResponseCommon(configurationResponseCommon).build();
998 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
999 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
1000 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1001 ResponseCodes.FINAL_ACK_YES);
1002 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
1006 public void deleteServicePathNotPassed() throws ExecutionException, InterruptedException {
1008 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1009 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
1010 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
1011 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1012 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1013 new ServiceInput(serviceDeleteInput));
1014 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1015 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1016 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1017 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1018 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
1019 .setConfigurationResponseCommon(configurationResponseCommon).build();
1020 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1021 Mockito.when(this.serviceDataStoreOperationsMock
1022 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1023 .thenReturn(OperationResult.failed("failed"));
1024 Mockito.when(this.serviceDataStoreOperationsMock
1025 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1026 .thenReturn(OperationResult.failed("failed"));
1027 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
1028 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1029 ResponseCodes.FINAL_ACK_YES);
1030 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1034 public void deleteServiceOperationNotPassed() throws ExecutionException, InterruptedException {
1036 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1037 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
1038 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
1039 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1040 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1041 new ServiceInput(serviceDeleteInput));
1042 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1043 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1044 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1045 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1046 .ServiceDeleteOutput output = new ServiceDeleteOutputBuilder()
1047 .setConfigurationResponseCommon(configurationResponseCommon).build();
1048 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1049 Mockito.when(this.serviceDataStoreOperationsMock
1050 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1051 .thenReturn(OperationResult.ok("success"));
1052 Mockito.when(this.serviceDataStoreOperationsMock
1053 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1054 .thenReturn(OperationResult.ok("success"));
1055 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
1056 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1057 ResponseCodes.FINAL_ACK_YES);
1058 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1062 public void deleteServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
1064 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1065 Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
1066 Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
1067 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1068 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1069 new ServiceInput(serviceDeleteInput));
1070 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1071 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1072 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1073 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1074 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
1075 .rev171017.ServiceDeleteOutputBuilder()
1076 .setConfigurationResponseCommon(configurationResponseCommon).build();
1077 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1078 Mockito.when(this.serviceDataStoreOperationsMock
1079 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1080 .thenReturn(OperationResult.ok("success"));
1081 Mockito.when(this.serviceDataStoreOperationsMock
1082 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1083 .thenReturn(OperationResult.ok("success"));
1084 ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
1085 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1086 ResponseCodes.FINAL_ACK_YES);
1087 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1091 public void deleteTempServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
1093 TempServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildTempServiceDeleteInput();
1094 Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
1095 .Services> service = Optional.of(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014
1096 .temp.service.list.ServicesBuilder().setCommonId("service 1").build());
1097 Mockito.when(this.serviceDataStoreOperationsMock.getTempService("service 1")).thenReturn(service);
1098 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1099 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(
1100 new ServiceInput(serviceDeleteInput));
1101 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1102 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1103 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1104 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1105 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
1106 .rev171017.ServiceDeleteOutputBuilder()
1107 .setConfigurationResponseCommon(configurationResponseCommon).build();
1108 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1109 Mockito.when(this.serviceDataStoreOperationsMock
1110 .deleteServicePath(serviceDeleteInput.getCommonId()))
1111 .thenReturn(OperationResult.ok("success"));
1112 Mockito.when(this.serviceDataStoreOperationsMock
1113 .deleteTempService(serviceDeleteInput.getCommonId()))
1114 .thenReturn(OperationResult.ok("success"));
1115 TempServiceDeleteOutput result = this.serviceHandlerImplMock.tempServiceDelete(serviceDeleteInput).get()
1117 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
1118 ResponseCodes.FINAL_ACK_YES);
1119 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
1123 public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
1125 ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
1126 ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
1127 Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
1128 Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
1133 public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
1135 ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
1136 ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1137 ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
1139 /** Mock RPC service-delete. */
1140 Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null);
1141 Optional<Services> service = Optional.of(serviceMock);
1142 Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
1143 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1144 .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
1145 ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1146 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1147 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1148 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017
1149 .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer
1150 .rev171017.ServiceDeleteOutputBuilder()
1151 .setConfigurationResponseCommon(configurationResponseCommon).build();
1152 Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1153 Mockito.when(this.serviceDataStoreOperationsMock
1154 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1155 .thenReturn(OperationResult.ok("success"));
1156 Mockito.when(this.serviceDataStoreOperationsMock
1157 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1158 .thenReturn(OperationResult.ok("success"));
1160 ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
1161 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1162 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1163 PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
1164 PceTestData.getPCE_simpletopology_test1_result((long) 5))
1165 .setConfigurationResponseCommon(configurationResponseCommon2).build();
1167 /** Mock RPC service-create. */
1168 Mockito.when(this.pceServiceWrapperMock.performPCE(any(ServiceCreateInput.class), any(Boolean.class)))
1169 .thenReturn(pathComputationRequestOutput);
1170 Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
1171 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
1172 Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceInput.class),
1173 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
1174 ConfigurationResponseCommon configurationResponseCommon3 = new ConfigurationResponseCommonBuilder()
1175 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1176 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
1178 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
1179 .thenReturn(new ServiceImplementationRequestOutputBuilder()
1180 .setConfigurationResponseCommon(configurationResponseCommon3).build());
1181 Mockito.when(this.serviceDataStoreOperationsMock.modifyService(any(String.class), any(State.class),
1182 any(State.class))).thenReturn(OperationResult.ok("successful"));
1184 ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
1185 Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
1186 result.getStatus());
1187 Assert.assertEquals("Service reroute successfully !", result.getStatusMessage());