clean some compilation warnings
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / impl / ServiceHandlerImplTest.java
1 /*
2  * Copyright © 2018 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.servicehandler.impl;
9
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.verify;
12
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;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.mockito.InjectMocks;
25 import org.mockito.Mock;
26 import org.mockito.Mockito;
27 import org.mockito.MockitoAnnotations;
28 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
29 import org.opendaylight.transportpce.common.OperationResult;
30 import org.opendaylight.transportpce.common.ResponseCodes;
31 import org.opendaylight.transportpce.pce.service.PathComputationService;
32 import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
33 import org.opendaylight.transportpce.pce.utils.NotificationPublishServiceMock;
34 import org.opendaylight.transportpce.pce.utils.PceTestData;
35 import org.opendaylight.transportpce.pce.utils.PceTestUtils;
36 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
37 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
38 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
39 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
40 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
41 import org.opendaylight.transportpce.servicehandler.stub.StubRendererServiceOperations;
42 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
43 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
44 import org.opendaylight.transportpce.test.AbstractTest;
45 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutputBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirectionBuilder;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirectionBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.Lgx;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutputBuilder;
72 import org.opendaylight.yangtools.yang.common.RpcResult;
73 import org.slf4j.Logger;
74 import org.slf4j.LoggerFactory;
75
76 public class ServiceHandlerImplTest extends AbstractTest {
77
78     private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerImplTest.class);
79
80     private PathComputationService pathComputationService;
81     private RendererServiceOperations rendererServiceOperations;
82     private ServicehandlerImpl serviceHandler;
83
84     @Mock
85     private ServiceDataStoreOperations serviceDataStoreOperationsMock;
86
87     @Mock
88     private PCEServiceWrapper pceServiceWrapperMock;
89
90     @Mock
91     private RendererServiceOperations rendererServiceOperationsMock;
92
93     @Mock
94     private ComplianceCheckResult complianceCheckResultMock;
95
96     @Mock
97     private Optional<Services> servicesOptionalMock;
98
99     @InjectMocks
100     private ServicehandlerImpl serviceHandlerImplMock;
101
102     @Before
103     public void setUp() {
104         this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService,
105                 this.rendererServiceOperations);
106         this.serviceHandlerImplMock = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
107         MockitoAnnotations.initMocks(this);
108     }
109
110     public ServiceHandlerImplTest() throws Exception {
111         NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
112         this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
113         PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
114                 "topologyData/NW-simple-topology.xml");
115         this.rendererServiceOperations = new StubRendererServiceOperations();
116     }
117
118     @Test
119     public void testCreateServiceValid() throws ExecutionException, InterruptedException {
120
121         ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
122         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
123                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
124                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
125         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
126                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
127                         .setConfigurationResponseCommon(configurationResponseCommon).build();
128
129         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceInput, true))
130             .thenReturn(pathComputationRequestOutput);
131         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
132                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
133         Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
134                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
135         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
136                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
137                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
138         Mockito.when(
139                 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
140                 .thenReturn(new ServiceImplementationRequestOutputBuilder()
141                         .setConfigurationResponseCommon(configurationResponseCommon2).build());
142         Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceInput.getServiceName(),
143                 State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
144
145         Future<RpcResult<ServiceCreateOutput>> output0 = this.serviceHandlerImplMock.serviceCreate(serviceInput);
146         Assert.assertNotNull(output0);
147         Assert.assertTrue(output0.get().isSuccessful());
148         Assert.assertEquals(output0.get().getResult(),
149                 ModelMappingUtils.createCreateServiceReply(serviceInput, ResponseCodes.FINAL_ACK_YES,
150                         "Service rendered successfully !", ResponseCodes.RESPONSE_OK).get().getResult());
151         Assert.assertEquals(0, output0.get().getErrors().size());
152     }
153
154     @Test
155     public void createServiceHandlerInvalidIfNameIsEmpty() throws ExecutionException, InterruptedException {
156         ServiceCreateInput emptyServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
157         ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyServiceNameInput);
158         emptyServiceNameInput = builtInput.setServiceName("").build();
159         Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceNameInput).get().getResult(),
160                 ModelMappingUtils.createCreateServiceReply(emptyServiceNameInput, ResponseCodes.FINAL_ACK_YES,
161                         "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
162     }
163
164     @Test
165     public void createServiceHandlerInvalidIfNameIsNull() throws ExecutionException, InterruptedException {
166         ServiceCreateInput nullServiceNameInput = ServiceDataUtils.buildServiceCreateInput();
167         ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(nullServiceNameInput);
168         nullServiceNameInput = builtInput.setServiceName(null).build();
169         Assert.assertEquals(this.serviceHandler.serviceCreate(nullServiceNameInput).get().getResult(),
170                 ModelMappingUtils.createCreateServiceReply(nullServiceNameInput, ResponseCodes.FINAL_ACK_YES,
171                         "Service Name is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
172     }
173
174     @Test
175     public void createServiceHnadlerInvalidIfConTypeIsEmpty() throws ExecutionException, InterruptedException {
176         ServiceCreateInput emptyConTypeInput = ServiceDataUtils.buildServiceCreateInput();
177         ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder(emptyConTypeInput);
178         emptyConTypeInput = builtInput.setConnectionType(null).build();
179         Assert.assertEquals(this.serviceHandler.serviceCreate(emptyConTypeInput).get().getResult(),
180                 ModelMappingUtils.createCreateServiceReply(emptyConTypeInput, ResponseCodes.FINAL_ACK_YES,
181                         "Service ConnectionType is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
182     }
183
184     @Test
185     public void createServiceHandlerInvalidIfSdncRequestHeaderNull() throws ExecutionException, InterruptedException {
186         ServiceCreateInput emptySdncRequestHeader = ServiceDataUtils.buildServiceCreateInput();
187         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptySdncRequestHeader);
188         emptySdncRequestHeader = buildInput.setSdncRequestHeader(null).build();
189         ServiceCreateOutput result = this.serviceHandler.serviceCreate(emptySdncRequestHeader).get().getResult();
190         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
191         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
192                 ResponseCodes.FINAL_ACK_YES);
193     }
194
195     @Test
196     public void createServiceHandlerInvalidIfRequestIdEmpty() throws ExecutionException, InterruptedException {
197         ServiceCreateInput emptyRequestId = ServiceDataUtils.buildServiceCreateInput();
198         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyRequestId);
199         emptyRequestId = buildInput
200                 .setSdncRequestHeader(
201                         new SdncRequestHeaderBuilder(emptyRequestId.getSdncRequestHeader()).setRequestId("").build())
202                 .build();
203         Assert.assertEquals(this.serviceHandler.serviceCreate(emptyRequestId).get().getResult(),
204                 ModelMappingUtils
205                         .createCreateServiceReply(emptyRequestId, ResponseCodes.FINAL_ACK_YES,
206                                 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
207                         .get().getResult());
208     }
209
210     @Test
211     public void createServiceHandlerInvalidIfRequestIdNull() throws ExecutionException, InterruptedException {
212         ServiceCreateInput nullRequestId = ServiceDataUtils.buildServiceCreateInput();
213         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(nullRequestId);
214         nullRequestId = buildInput
215                 .setSdncRequestHeader(
216                         new SdncRequestHeaderBuilder(nullRequestId.getSdncRequestHeader()).setRequestId(null).build())
217                 .build();
218         Assert.assertEquals(this.serviceHandler.serviceCreate(nullRequestId).get().getResult(),
219                 ModelMappingUtils
220                         .createCreateServiceReply(nullRequestId, ResponseCodes.FINAL_ACK_YES,
221                                 "Service sdncRequestHeader 'request-id' is not set", ResponseCodes.RESPONSE_FAILED)
222                         .get().getResult());
223     }
224
225     @Test
226     public void serviceHandlerInvalidServiceActionIsNull() throws ExecutionException, InterruptedException {
227         ServiceCreateInput emptyServiceAction = ServiceDataUtils.buildServiceCreateInput();
228         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(emptyServiceAction);
229         emptyServiceAction = buildInput.setSdncRequestHeader(
230                 new SdncRequestHeaderBuilder(emptyServiceAction.getSdncRequestHeader()).setRpcAction(null).build())
231                 .build();
232         Assert.assertEquals(this.serviceHandler.serviceCreate(emptyServiceAction).get().getResult(),
233                 ModelMappingUtils
234                         .createCreateServiceReply(emptyServiceAction, ResponseCodes.FINAL_ACK_YES,
235                                 "Service sndc-request-header 'rpc-action' is not set ", ResponseCodes.RESPONSE_FAILED)
236                         .get().getResult());
237     }
238
239     @Test
240     public void serviceHandlerInvalidServiceActionIsNotCreate() throws ExecutionException, InterruptedException {
241         ServiceCreateInput notCreateServiceAction = ServiceDataUtils.buildServiceCreateInput();
242         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notCreateServiceAction);
243         notCreateServiceAction = buildInput
244                 .setSdncRequestHeader(new SdncRequestHeaderBuilder(notCreateServiceAction.getSdncRequestHeader())
245                         .setRpcAction(RpcActions.ServiceFeasibilityCheck).build())
246                 .build();
247         Assert.assertEquals(this.serviceHandler.serviceCreate(notCreateServiceAction).get().getResult(),
248                 ModelMappingUtils.createCreateServiceReply(notCreateServiceAction, ResponseCodes.FINAL_ACK_YES,
249                         "Service sdncRequestHeader rpc-action '"
250                                 + notCreateServiceAction.getSdncRequestHeader().getRpcAction() + "' not equal to '"
251                                 + RpcActions.ServiceCreate.name() + "'",
252                         ResponseCodes.RESPONSE_FAILED).get().getResult());
253     }
254
255     @Test
256     public void createServiceHandlerNotValidServiceAEndIsNull() throws ExecutionException, InterruptedException {
257         ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
258         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
259         notValidServiceAEnd = buildInput.setServiceAEnd(null).build();
260         Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
261                 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
262                         "SERVICEAEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
263     }
264
265     @Test
266     public void createServiceHandlerNotValidServiceZEndIsNull() throws ExecutionException, InterruptedException {
267         ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
268         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
269         notValidServiceAEnd = buildInput.setServiceZEnd(null).build();
270         Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
271                 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
272                         "SERVICEZEND is not set", ResponseCodes.RESPONSE_FAILED).get().getResult());
273     }
274
275     @Test
276     public void createServiceHandlerNotValidServiceAEndRateIsNull() throws ExecutionException, InterruptedException {
277         ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
278         ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
279         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
280         notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setServiceRate(null)
281                 .build()).build();
282         Assert.assertEquals(servicehandler.serviceCreate(notValidServiceAEnd).get().getResult(),
283                 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
284                         "Service " + ServiceEndpointType.SERVICEAEND + " rate is not set",
285                         ResponseCodes.RESPONSE_FAILED).get().getResult());
286     }
287
288     @Test
289     public void createServiceHandlerNotValidServiceZEndRateIsNull() throws ExecutionException, InterruptedException {
290         ServicehandlerImpl servicehandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
291         ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
292         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
293         notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setServiceRate(null)
294                 .build()).build();
295         Assert.assertEquals(servicehandler.serviceCreate(notValidServiceZEnd).get().getResult(),
296                 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
297                         "Service " + ServiceEndpointType.SERVICEZEND + " rate is not set",
298                         ResponseCodes.RESPONSE_FAILED).get().getResult());
299     }
300
301     @Test
302     public void createServiceHandlerNotValidServiceAEndClliIsNull()
303             throws ExecutionException, InterruptedException {
304         ServiceCreateInput notValidServiceAEnd = ServiceDataUtils.buildServiceCreateInput();
305         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceAEnd);
306         notValidServiceAEnd = buildInput.setServiceAEnd(ServiceDataUtils.getServiceAEndBuild().setClli(null)
307                 .build()).build();
308         Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceAEnd).get().getResult(),
309                 ModelMappingUtils.createCreateServiceReply(notValidServiceAEnd, ResponseCodes.FINAL_ACK_YES,
310                         "Service" + ServiceEndpointType.SERVICEAEND + " clli format is not set",
311                         ResponseCodes.RESPONSE_FAILED).get().getResult());
312     }
313
314     @Test
315     public void createServiceHandlerNotValidServiceZEndClliIsNull()
316             throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
317         ServiceCreateInput notValidServiceZEnd = ServiceDataUtils.buildServiceCreateInput();
318         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(notValidServiceZEnd);
319         notValidServiceZEnd = buildInput.setServiceZEnd(ServiceDataUtils.getServiceZEndBuild().setClli(null).build())
320                 .build();
321         Assert.assertEquals(this.serviceHandler.serviceCreate(notValidServiceZEnd).get().getResult(),
322                 ModelMappingUtils.createCreateServiceReply(notValidServiceZEnd, ResponseCodes.FINAL_ACK_YES,
323                         "Service" + ServiceEndpointType.SERVICEZEND + " clli format is not set",
324                         ResponseCodes.RESPONSE_FAILED).get().getResult());
325     }
326
327     @Test
328     public void createServiceHandlerNotValidServiceAEndAttributes()
329             throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
330         HashMap<String, Object> notValidData = new HashMap<>();
331         notValidData.put("setServiceRate", 0L);
332         notValidData.put("setServiceFormat", null);
333         notValidData.put("setClli", "");
334         notValidData.put("setTxDirection", null);
335         notValidData.put("setRxDirection", null);
336         for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
337                 .ServiceAEndBuilder.class.getDeclaredMethods()) {
338             if (notValidData.containsKey(method.getName())) {
339                 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
340                         .buildServiceCreateInput());
341                 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
342                     .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
343                 method.invoke(serviceAEndBuilder, notValidData.get(method.getName()));
344                 ServiceCreateOutput result = this.serviceHandler
345                         .serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get().getResult();
346                 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
347                         ResponseCodes.FINAL_ACK_YES);
348                 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
349                         ResponseCodes.RESPONSE_FAILED);
350             }
351         }
352     }
353
354     @Test
355     public void createServiceHandlerNotValidServiceZEndAttributes()
356             throws ExecutionException, InterruptedException, InvocationTargetException, IllegalAccessException {
357         HashMap<String, Object> notValidData = new HashMap<>();
358         notValidData.put("setServiceRate", 0L);
359         notValidData.put("setServiceFormat", null);
360         notValidData.put("setClli", "");
361         notValidData.put("setTxDirection", null);
362         notValidData.put("setRxDirection", null);
363         for (Method method : org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
364                 .ServiceZEndBuilder.class.getDeclaredMethods()) {
365             if (notValidData.containsKey(method.getName())) {
366                 ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(ServiceDataUtils
367                         .buildServiceCreateInput());
368                 org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
369                     .ServiceZEndBuilder serviceZEndBuilder = ServiceDataUtils.getServiceZEndBuild();
370                 method.invoke(serviceZEndBuilder, notValidData.get(method.getName()));
371                 ServiceCreateOutput result = this.serviceHandler
372                         .serviceCreate(buildInput.setServiceZEnd(serviceZEndBuilder.build()).build()).get().getResult();
373                 Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
374                         ResponseCodes.FINAL_ACK_YES);
375                 Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
376                         ResponseCodes.RESPONSE_FAILED);
377             }
378         }
379     }
380
381     @Test
382     public void createServiceHandlerNotValidTxDirectionPort()
383             throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
384         List<String> invalidData = Arrays.asList(null, "");
385         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
386         for (Method method : PortBuilder.class.getMethods()) {
387             if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
388                 for (Object data : invalidData) {
389                     PortBuilder portBuilder = new PortBuilder(
390                             serviceCreateInput.getServiceAEnd().getTxDirection().getPort());
391                     method.invoke(portBuilder, data);
392                     ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(portBuilder.build(),
393                             serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
394                     Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
395                             ResponseCodes.FINAL_ACK_YES);
396                     Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
397                             ResponseCodes.RESPONSE_FAILED);
398                 }
399             }
400         }
401     }
402
403     @Test
404     public void createServiceHandlerTxDirectionPortIsNull() throws ExecutionException, InterruptedException {
405         ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(null,
406             ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getLgx());
407         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
408                 ResponseCodes.FINAL_ACK_YES);
409         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
410     }
411
412     @Test
413     public void createServiceHandlerNotValidTxDirectionLgx()
414             throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
415         List<String> invalidData = Arrays.asList(null, "");
416         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
417         for (Method method : LgxBuilder.class.getMethods()) {
418             if (method.getName().startsWith("set")) {
419                 for (Object data : invalidData) {
420                     LgxBuilder lgxBuilder = new LgxBuilder(
421                             serviceCreateInput.getServiceAEnd().getTxDirection().getLgx());
422                     method.invoke(lgxBuilder, data);
423                     ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
424                             serviceCreateInput.getServiceAEnd().getTxDirection().getPort(), lgxBuilder.build());
425                     Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
426                             ResponseCodes.FINAL_ACK_YES);
427                     Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
428                             ResponseCodes.RESPONSE_FAILED);
429                 }
430             }
431         }
432     }
433
434     @Test
435     public void createServiceHandlerTxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
436         ServiceCreateOutput result = getTxDirectionPortServiceCreateOutput(
437             ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getTxDirection().getPort(), null);
438         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
439                 ResponseCodes.FINAL_ACK_YES);
440         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
441     }
442
443     private ServiceCreateOutput getTxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
444             throws InterruptedException, ExecutionException {
445         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
446         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
447             .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
448         TxDirectionBuilder txDirectionBuilder = new TxDirectionBuilder(
449                 serviceCreateInput.getServiceAEnd().getTxDirection());
450         txDirectionBuilder.setPort(port);
451         txDirectionBuilder.setLgx(lgx);
452         serviceAEndBuilder.setTxDirection(txDirectionBuilder.build());
453         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
454         this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
455         return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
456                 .getResult();
457     }
458
459     @Test
460     public void createServiceHandlerNotValidRxDirectionPort()
461             throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
462         List<String> invalidData = Arrays.asList(null, "");
463         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
464         for (Method method : PortBuilder.class.getMethods()) {
465             if (method.getName().startsWith("set") && !method.getName().contains("Slot")) {
466                 for (Object data : invalidData) {
467                     PortBuilder portBuilder = new PortBuilder(
468                             serviceCreateInput.getServiceAEnd().getRxDirection().getPort());
469                     method.invoke(portBuilder, data);
470                     ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(portBuilder.build(),
471                             serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
472                     Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
473                             ResponseCodes.FINAL_ACK_YES);
474                     Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
475                             ResponseCodes.RESPONSE_FAILED);
476                 }
477             }
478         }
479     }
480
481     @Test
482     public void createServiceHandlerRxDirectionPortIsNull()
483             throws ExecutionException, InterruptedException {
484         ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(null,
485             ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getLgx());
486         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
487                 ResponseCodes.FINAL_ACK_YES);
488         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
489     }
490
491     @Test
492     public void createServiceHandlerNotValidRxDirectionLgx()
493             throws InvocationTargetException, IllegalAccessException, ExecutionException, InterruptedException {
494         List<String> invalidData = Arrays.asList(null, "");
495         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
496         for (Method method : LgxBuilder.class.getMethods()) {
497             if (method.getName().startsWith("set")) {
498                 for (Object data : invalidData) {
499                     LgxBuilder lgxBuilder = new LgxBuilder(
500                             serviceCreateInput.getServiceAEnd().getRxDirection().getLgx());
501                     method.invoke(lgxBuilder, data);
502                     ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
503                             serviceCreateInput.getServiceAEnd().getRxDirection().getPort(), lgxBuilder.build());
504                     Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
505                             ResponseCodes.FINAL_ACK_YES);
506                     Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(),
507                             ResponseCodes.RESPONSE_FAILED);
508                 }
509             }
510         }
511     }
512
513     @Test
514     public void createServiceHandlerRxDirectionLgxIsNull() throws ExecutionException, InterruptedException {
515         ServiceCreateOutput result = getRxDirectionPortServiceCreateOutput(
516             ServiceDataUtils.buildServiceCreateInput().getServiceAEnd().getRxDirection().getPort(), null);
517         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
518                 ResponseCodes.FINAL_ACK_YES);
519         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
520     }
521
522     @Test
523     public void createServiceHandlerResponseCodesNotPassed() throws ExecutionException, InterruptedException {
524         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
525
526         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
527                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
528                 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failed").build();
529         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
530                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
531                         .setConfigurationResponseCommon(configurationResponseCommon).build();
532         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
533                 .thenReturn(pathComputationRequestOutput);
534         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
535         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
536                 ResponseCodes.FINAL_ACK_YES);
537         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
538         verify(this.pceServiceWrapperMock).performPCE(serviceCreateInput, true);
539     }
540
541     @Test
542     public void createServiceHandlerOperationResultNotPassed() throws ExecutionException, InterruptedException {
543         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
544         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
545                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
546                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
547         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
548                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
549                         .setConfigurationResponseCommon(configurationResponseCommon).build();
550         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
551                 .thenReturn(pathComputationRequestOutput);
552         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
553                 any(PathComputationRequestOutput.class)))
554                 .thenReturn(OperationResult.failed(
555                         "Failed to create service " + serviceCreateInput.getServiceName() + " to Service List"));
556         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
557         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
558                 ResponseCodes.FINAL_ACK_YES);
559         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
560         verify(this.serviceDataStoreOperationsMock).createService(any(ServiceCreateInput.class),
561                 any(PathComputationRequestOutput.class));
562     }
563
564     @Test
565     public void createServiceHandlerOperationServicePathSaveResultNotPassed()
566             throws ExecutionException, InterruptedException {
567         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
568         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
569                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
570                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
571         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
572                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
573                         .setConfigurationResponseCommon(configurationResponseCommon).build();
574         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
575                 .thenReturn(pathComputationRequestOutput);
576         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
577                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
578         Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
579                 any(PathComputationRequestOutput.class)))
580                 .thenReturn(OperationResult.failed("Failed to create servicePath " + serviceCreateInput.getServiceName()
581                         + " to ServicePath List"));
582         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
583         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
584                 ResponseCodes.FINAL_ACK_YES);
585         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
586         verify(this.serviceDataStoreOperationsMock).createServicePath(any(ServiceCreateInput.class),
587                 any(PathComputationRequestOutput.class));
588     }
589
590     @Test
591     public void createServiceHandlerModifyServicePassed() throws ExecutionException, InterruptedException {
592         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
593         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
594                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
595                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").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         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
602                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
603         Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
604                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
605         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
606                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
607                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
608
609         Mockito.when(
610                 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
611                 .thenReturn(new ServiceImplementationRequestOutputBuilder()
612                         .setConfigurationResponseCommon(configurationResponseCommon2).build());
613         Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
614                 State.InService, State.InService)).thenReturn(OperationResult.ok("successful"));
615         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
616         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
617                 ResponseCodes.FINAL_ACK_YES);
618         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
619         verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
620                 State.InService);
621     }
622
623     @Test
624     public void createServiceHandlerModifyServiceNotPassed() throws ExecutionException, InterruptedException {
625         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
626         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
627                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
628                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
629         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
630                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
631                         .setConfigurationResponseCommon(configurationResponseCommon).build();
632         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
633                 .thenReturn(pathComputationRequestOutput);
634         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
635                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
636         Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
637                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
638         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
639                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
640                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
641
642         Mockito.when(
643                 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
644                 .thenReturn(new ServiceImplementationRequestOutputBuilder()
645                         .setConfigurationResponseCommon(configurationResponseCommon2).build());
646         Mockito.when(this.serviceDataStoreOperationsMock.modifyService(serviceCreateInput.getServiceName(),
647                 State.InService, State.InService)).thenReturn(OperationResult.failed("failure"));
648         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
649         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
650                 ResponseCodes.FINAL_ACK_YES);
651         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
652         verify(this.serviceDataStoreOperationsMock).modifyService(serviceCreateInput.getServiceName(), State.InService,
653                 State.InService);
654     }
655
656     @Test
657     public void createServiceHandlerServiceImplementationNotPassed() throws ExecutionException, InterruptedException {
658         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
659         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
660                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
661                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
662         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
663                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
664                         .setConfigurationResponseCommon(configurationResponseCommon).build();
665         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
666                 .thenReturn(pathComputationRequestOutput);
667         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
668                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
669         Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
670                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
671         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
672                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
673                 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
674
675         Mockito.when(
676                 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
677                 .thenReturn(new ServiceImplementationRequestOutputBuilder()
678                         .setConfigurationResponseCommon(configurationResponseCommon2).build());
679         Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
680                 .thenReturn(OperationResult.ok("successful"));
681         Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
682                 .thenReturn(OperationResult.ok("successful"));
683         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
684         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
685                 ResponseCodes.FINAL_ACK_YES);
686         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
687         verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
688         verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
689     }
690
691     @Test
692     public void createServiceHandlerServiceImplementationNotPassed2() throws ExecutionException, InterruptedException {
693         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
694         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
695                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
696                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
697         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
698                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
699                         .setConfigurationResponseCommon(configurationResponseCommon).build();
700         Mockito.when(this.pceServiceWrapperMock.performPCE(serviceCreateInput, true))
701                 .thenReturn(pathComputationRequestOutput);
702         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
703                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
704         Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
705                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
706         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
707                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO).setRequestId("1")
708                 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("failure").build();
709
710         Mockito.when(
711                 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
712                 .thenReturn(new ServiceImplementationRequestOutputBuilder()
713                         .setConfigurationResponseCommon(configurationResponseCommon2).build());
714         Mockito.when(this.serviceDataStoreOperationsMock.deleteService(serviceCreateInput.getServiceName()))
715                 .thenReturn(OperationResult.failed("successful"));
716         Mockito.when(this.serviceDataStoreOperationsMock.deleteServicePath(serviceCreateInput.getServiceName()))
717                 .thenReturn(OperationResult.failed("successful"));
718         ServiceCreateOutput result = this.serviceHandlerImplMock.serviceCreate(serviceCreateInput).get().getResult();
719         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
720                 ResponseCodes.FINAL_ACK_YES);
721         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
722         verify(this.serviceDataStoreOperationsMock).deleteService(serviceCreateInput.getServiceName());
723         verify(this.serviceDataStoreOperationsMock).deleteServicePath(serviceCreateInput.getServiceName());
724     }
725
726     private ServiceCreateOutput getRxDirectionPortServiceCreateOutput(Port port, Lgx lgx)
727             throws InterruptedException, ExecutionException {
728         ServiceCreateInput serviceCreateInput = ServiceDataUtils.buildServiceCreateInput();
729         org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input
730             .ServiceAEndBuilder serviceAEndBuilder = ServiceDataUtils.getServiceAEndBuild();
731         RxDirectionBuilder rxDirectionBuilder = new RxDirectionBuilder(
732                 serviceCreateInput.getServiceAEnd().getRxDirection());
733         rxDirectionBuilder.setPort(port);
734         rxDirectionBuilder.setLgx(lgx);
735         serviceAEndBuilder.setRxDirection(rxDirectionBuilder.build());
736         ServiceCreateInputBuilder buildInput = new ServiceCreateInputBuilder(serviceCreateInput);
737         this.serviceHandler = new ServicehandlerImpl(getDataBroker(), this.pathComputationService, null);
738         return serviceHandler.serviceCreate(buildInput.setServiceAEnd(serviceAEndBuilder.build()).build()).get()
739                 .getResult();
740     }
741
742     @Test
743     public void deleteServiceInvalidIfServiceNameIsEmpty() throws ExecutionException, InterruptedException {
744
745         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
746         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
747         serviceDeleteInput = builder
748                 .setServiceDeleteReqInfo(
749                         new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName("").build())
750                 .build();
751         ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
752         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
753                 ResponseCodes.FINAL_ACK_YES);
754         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
755     }
756
757     @Test
758     public void deleteServiceInvalidIfServiceNameIsNull() throws ExecutionException, InterruptedException {
759
760         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
761         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
762         serviceDeleteInput = builder
763                 .setServiceDeleteReqInfo(
764                         new ServiceDeleteReqInfoBuilder(builder.getServiceDeleteReqInfo()).setServiceName(null).build())
765                 .build();
766         ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
767         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
768                 ResponseCodes.FINAL_ACK_YES);
769         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
770     }
771
772     @Test
773     public void deleteServiceInvalidIfSdncRequestHeaderIsNull() throws ExecutionException, InterruptedException {
774         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
775         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
776         serviceDeleteInput = builder.setSdncRequestHeader(null).build();
777         ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
778         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
779                 ResponseCodes.FINAL_ACK_YES);
780         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
781     }
782
783     @Test
784     public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsNull()
785             throws ExecutionException, InterruptedException {
786
787         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
788         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
789         serviceDeleteInput = builder
790                 .setSdncRequestHeader(
791                         new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId(null).build())
792                 .build();
793         ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
794         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
795                 ResponseCodes.FINAL_ACK_YES);
796         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
797     }
798
799     @Test
800     public void deleteServiceInvalidIfSdncRequestHeaderRequestIdIsEmpty()
801             throws ExecutionException, InterruptedException {
802
803         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
804         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
805         serviceDeleteInput = builder.setSdncRequestHeader(
806                 new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRequestId("").build()).build();
807         ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
808         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
809                 ResponseCodes.FINAL_ACK_YES);
810         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
811     }
812
813     @Test
814     public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNull()
815             throws ExecutionException, InterruptedException {
816
817         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
818         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
819         serviceDeleteInput = builder
820                 .setSdncRequestHeader(
821                         new SdncRequestHeaderBuilder(builder.getSdncRequestHeader()).setRpcAction(null).build())
822                 .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);
827     }
828
829     @Test
830     public void deleteServiceInvalidIfSdncRequestHeaderServiceActionIsNotDelete()
831             throws ExecutionException, InterruptedException {
832
833         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
834         ServiceDeleteInputBuilder builder = new ServiceDeleteInputBuilder(serviceDeleteInput);
835         serviceDeleteInput = builder.setSdncRequestHeader(new SdncRequestHeaderBuilder(builder.getSdncRequestHeader())
836                 .setRpcAction(RpcActions.ServiceCreate).build()).build();
837         ServiceDeleteOutput result = this.serviceHandler.serviceDelete(serviceDeleteInput).get().getResult();
838         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
839                 ResponseCodes.FINAL_ACK_YES);
840         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
841     }
842
843     @Test
844     public void deleteServiceIfServiceHandlerCompliancyCheckNotPassed()
845             throws ExecutionException, InterruptedException {
846
847         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
848
849         Mockito.when(this.complianceCheckResultMock.hasPassed()).thenReturn(false);
850
851         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
852         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
853                 ResponseCodes.FINAL_ACK_YES);
854         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
855     }
856
857     @Test
858     public void deleteServiceNotPresent() throws ExecutionException, InterruptedException {
859
860         ServiceDeleteOutput result = this.serviceHandler.serviceDelete(ServiceDataUtils.buildServiceDeleteInput()).get()
861                 .getResult();
862         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
863                 ResponseCodes.FINAL_ACK_YES);
864         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
865     }
866
867     @Test
868     public void deleteServiceIfServiceNotPresent() throws ExecutionException, InterruptedException {
869
870         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
871         Mockito.when(this.servicesOptionalMock.isPresent()).thenReturn(false);
872         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
873         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
874                 ResponseCodes.FINAL_ACK_YES);
875         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
876     }
877
878     @Test
879     public void deleteServiceNotPassed() throws ExecutionException, InterruptedException {
880
881         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
882         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
883         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
884         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
885             .ServiceDeleteInput input = ModelMappingUtils
886                 .createServiceDeleteInput(serviceDeleteInput);
887         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
888                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
889                 .setResponseCode(ResponseCodes.RESPONSE_FAILED).setResponseMessage("success").build();
890         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
891             .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
892                 .servicepath.rev170426.ServiceDeleteOutputBuilder()
893                 .setConfigurationResponseCommon(configurationResponseCommon).build();
894         Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
895         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
896         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
897                 ResponseCodes.FINAL_ACK_YES);
898         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_FAILED);
899     }
900
901     @Test
902     public void deleteServicePathNotPassed() throws ExecutionException, InterruptedException {
903
904         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
905         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
906         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
907         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
908             .ServiceDeleteInput input = ModelMappingUtils
909                 .createServiceDeleteInput(serviceDeleteInput);
910         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
911                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
912                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
913         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
914             .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
915                 .servicepath.rev170426.ServiceDeleteOutputBuilder()
916                 .setConfigurationResponseCommon(configurationResponseCommon).build();
917         Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
918         Mockito.when(this.serviceDataStoreOperationsMock
919                 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
920                 .thenReturn(OperationResult.failed("failed"));
921         Mockito.when(this.serviceDataStoreOperationsMock
922                 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
923                 .thenReturn(OperationResult.failed("failed"));
924         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
925         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
926                 ResponseCodes.FINAL_ACK_YES);
927         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
928     }
929
930     @Test
931     public void deleteServiceOperationNotPassed() throws ExecutionException, InterruptedException {
932
933         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
934         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
935         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
936         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
937             .ServiceDeleteInput input = ModelMappingUtils
938                 .createServiceDeleteInput(serviceDeleteInput);
939         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
940                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
941                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
942         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
943             .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
944                 .servicepath.rev170426.ServiceDeleteOutputBuilder()
945                 .setConfigurationResponseCommon(configurationResponseCommon).build();
946         Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
947         Mockito.when(this.serviceDataStoreOperationsMock
948                 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
949                 .thenReturn(OperationResult.ok("success"));
950         Mockito.when(this.serviceDataStoreOperationsMock
951                 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
952                 .thenReturn(OperationResult.ok("success"));
953         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
954         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
955                 ResponseCodes.FINAL_ACK_YES);
956         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
957     }
958
959     @Test
960     public void deleteServiceIfServicePresentAndValid() throws ExecutionException, InterruptedException {
961
962         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
963         Optional<Services> service = Optional.of(new ServicesBuilder().setServiceName("service 1").build());
964         Mockito.when(this.serviceDataStoreOperationsMock.getService("service 1")).thenReturn(service);
965         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
966             .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceDeleteInput);
967         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
968                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
969                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
970         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
971             .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
972                 .servicepath.rev170426.ServiceDeleteOutputBuilder()
973                 .setConfigurationResponseCommon(configurationResponseCommon).build();
974         Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
975         Mockito.when(this.serviceDataStoreOperationsMock
976                 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
977                 .thenReturn(OperationResult.ok("success"));
978         Mockito.when(this.serviceDataStoreOperationsMock
979                 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
980                 .thenReturn(OperationResult.ok("success"));
981         ServiceDeleteOutput result = this.serviceHandlerImplMock.serviceDelete(serviceDeleteInput).get().getResult();
982         Assert.assertEquals(result.getConfigurationResponseCommon().getAckFinalIndicator(),
983                 ResponseCodes.FINAL_ACK_YES);
984         Assert.assertEquals(result.getConfigurationResponseCommon().getResponseCode(), ResponseCodes.RESPONSE_OK);
985     }
986
987     @Test
988     public void rerouteServiceIsNotPresent() throws ExecutionException, InterruptedException {
989
990         ServiceRerouteInput input = ServiceDataUtils.buildServiceRerouteInput();
991         ServiceRerouteOutput result = this.serviceHandler.serviceReroute(input).get().getResult();
992         Assert.assertEquals(result.getStatus(), RpcStatus.Failed);
993         Assert.assertEquals(result.getStatusMessage(), "Service 'service 1' is not present");
994
995     }
996
997     @Test
998     public void rerouteServiceIfserviceIsPresent() throws ExecutionException, InterruptedException {
999
1000         ServiceRerouteInput serviceRerouteinput = ServiceDataUtils.buildServiceRerouteInput();
1001         ServiceDeleteInput serviceDeleteInput = ServiceDataUtils.buildServiceDeleteInput();
1002         ServiceCreateInput serviceInput = ServiceDataUtils.buildServiceCreateInput();
1003
1004         /** Mock RPC service-delete. */
1005         Services serviceMock = ModelMappingUtils.mappingServices(serviceInput, null, null);
1006         Optional<Services> service = Optional.of(serviceMock);
1007         Mockito.when(this.serviceDataStoreOperationsMock.getService(any(String.class))).thenReturn(service);
1008         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
1009             .ServiceDeleteInput input = ModelMappingUtils.createServiceDeleteInput(serviceRerouteinput, service.get());
1010         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
1011                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1012                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1013         org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426
1014             .ServiceDeleteOutput output = new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
1015                 .servicepath.rev170426.ServiceDeleteOutputBuilder()
1016                 .setConfigurationResponseCommon(configurationResponseCommon).build();
1017         Mockito.when(this.rendererServiceOperationsMock.serviceDelete(input)).thenReturn(output);
1018         Mockito.when(this.serviceDataStoreOperationsMock
1019                 .deleteServicePath(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1020                 .thenReturn(OperationResult.ok("success"));
1021         Mockito.when(this.serviceDataStoreOperationsMock
1022                 .deleteService(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()))
1023                 .thenReturn(OperationResult.ok("success"));
1024
1025         ConfigurationResponseCommon configurationResponseCommon2 = new ConfigurationResponseCommonBuilder()
1026                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1027                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("success").build();
1028         PathComputationRequestOutput pathComputationRequestOutput = new PathComputationRequestOutputBuilder(
1029                 PceTestData.getPCE_simpletopology_test1_result((long) 5))
1030                         .setConfigurationResponseCommon(configurationResponseCommon2).build();
1031
1032         /** Mock RPC service-create. */
1033         Mockito.when(this.pceServiceWrapperMock.performPCE(any(ServiceCreateInput.class), any(Boolean.class)))
1034             .thenReturn(pathComputationRequestOutput);
1035         Mockito.when(this.serviceDataStoreOperationsMock.createService(any(ServiceCreateInput.class),
1036                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
1037         Mockito.when(this.serviceDataStoreOperationsMock.createServicePath(any(ServiceCreateInput.class),
1038                 any(PathComputationRequestOutput.class))).thenReturn(OperationResult.ok("Successful"));
1039         ConfigurationResponseCommon configurationResponseCommon3 = new ConfigurationResponseCommonBuilder()
1040                 .setAckFinalIndicator(ResponseCodes.FINAL_ACK_YES).setRequestId("1")
1041                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("successful").build();
1042         Mockito.when(
1043                 this.rendererServiceOperationsMock.serviceImplementation(any(ServiceImplementationRequestInput.class)))
1044                 .thenReturn(new ServiceImplementationRequestOutputBuilder()
1045                         .setConfigurationResponseCommon(configurationResponseCommon3).build());
1046         Mockito.when(this.serviceDataStoreOperationsMock.modifyService(any(String.class), any(State.class),
1047                 any(State.class))).thenReturn(OperationResult.ok("successful"));
1048
1049         ServiceRerouteOutput result = this.serviceHandlerImplMock.serviceReroute(serviceRerouteinput).get().getResult();
1050         Assert.assertEquals(org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus.Successful,
1051                 result.getStatus());
1052         Assert.assertEquals("Service reroute successfully !", result.getStatusMessage());
1053     }
1054 }