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