Sync Common folder
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / provisiondevice / RendererServiceOperationsImplTest.java
1 /*
2  * Copyright © 2018 Orange Systems, 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.renderer.provisiondevice;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import java.util.concurrent.ExecutionException;
13
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.mockito.Mockito;
18 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
19 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
20 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
21 import org.opendaylight.transportpce.common.ResponseCodes;
22 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
23 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
24 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl121;
25 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl22;
26 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
27 import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
28 import org.opendaylight.transportpce.common.mapping.MappingUtils;
29 import org.opendaylight.transportpce.common.mapping.MappingUtilsImpl;
30 import org.opendaylight.transportpce.common.mapping.PortMapping;
31 import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
32 import org.opendaylight.transportpce.common.mapping.PortMappingVersion121;
33 import org.opendaylight.transportpce.common.mapping.PortMappingVersion22;
34 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
35 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
36 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
37 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl121;
38 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl22;
39 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
40 import org.opendaylight.transportpce.renderer.NetworkModelWavelengthServiceImpl;
41 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
42 import org.opendaylight.transportpce.renderer.stub.MountPointServiceStub;
43 import org.opendaylight.transportpce.renderer.stub.MountPointStub;
44 import org.opendaylight.transportpce.renderer.stub.OlmServiceStub;
45 import org.opendaylight.transportpce.renderer.utils.MountPointUtils;
46 import org.opendaylight.transportpce.renderer.utils.NotificationPublishServiceMock;
47 import org.opendaylight.transportpce.renderer.utils.ServiceDataUtils;
48 import org.opendaylight.transportpce.test.AbstractTest;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInput;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInputBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.TransportpceOlmService;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.Measurements;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.MeasurementsBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathOutputBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
58 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
61 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.get.pm.input.ResourceIdentifierBuilder;
62 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
63
64 public class RendererServiceOperationsImplTest extends AbstractTest {
65
66     private MountPointService mountPointService;
67     private DeviceTransactionManager deviceTransactionManager;
68     private RendererServiceOperationsImpl rendererServiceOperations;
69     private OpenRoadmInterfaces openRoadmInterfaces;
70     private DeviceRendererService deviceRenderer;
71     private PortMapping portMapping;
72     private OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
73     private CrossConnect crossConnect;
74     private TransportpceOlmService olmService;
75     private NetworkModelWavelengthService networkModelWavelengthService;
76     private MappingUtils mappingUtils;
77     private OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121;
78     private OpenRoadmInterfacesImpl22 openRoadmInterfacesImpl22;
79     private PortMappingVersion22 portMappingVersion22;
80     private PortMappingVersion121 portMappingVersion121;
81     private CrossConnectImpl121 crossConnectImpl121;
82     private CrossConnectImpl22 crossConnectImpl22;
83
84     private void setMountPoint(MountPoint mountPoint) {
85         this.mountPointService = new MountPointServiceStub(mountPoint);
86         this.deviceTransactionManager = new DeviceTransactionManagerImpl(this.mountPointService, 3000);
87         this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
88         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl22(deviceTransactionManager);
89         this.mappingUtils = new MappingUtilsImpl(getDataBroker());
90         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl(deviceTransactionManager, mappingUtils,
91                 openRoadmInterfacesImpl121, openRoadmInterfacesImpl22);
92         this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces);
93         this.portMappingVersion22 =
94                 new PortMappingVersion22(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
95         this.portMappingVersion121 =
96                 new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
97         this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion22, this.mappingUtils,
98                 this.portMappingVersion121);
99         this.openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(portMapping,
100             openRoadmInterfaces);
101         this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager);
102         this.crossConnectImpl22 = new CrossConnectImpl22(deviceTransactionManager);
103         this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121,
104                 this.crossConnectImpl22);
105     }
106
107     @Before
108     public void setUp() throws OpenRoadmInterfaceException {
109         setMountPoint(new MountPointStub(getDataBroker()));
110         this.olmService = new OlmServiceStub();
111         this.networkModelWavelengthService = new NetworkModelWavelengthServiceImpl(getDataBroker());
112         this.deviceRenderer = new DeviceRendererServiceImpl(this.getDataBroker(),
113             this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect, portMapping);
114         Mockito.doNothing().when(this.openRoadmInterfaces).postEquipmentState(Mockito.anyString(),
115             Mockito.anyString(), Mockito.anyBoolean());
116         NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
117
118         this.olmService = Mockito.spy(this.olmService);
119         this.deviceRenderer = Mockito.spy(this.deviceRenderer);
120         this.rendererServiceOperations =  new RendererServiceOperationsImpl(this.deviceRenderer, this.olmService,
121             getDataBroker(), this.networkModelWavelengthService, notificationPublishService);
122
123         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
124             .setSuccess(true);
125         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
126             Mockito.any());
127     }
128
129     @Test
130     public void serviceImplementationTerminationPointAsResourceTtp() throws InterruptedException, ExecutionException {
131
132         ServiceImplementationRequestInput input = ServiceDataUtils
133             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.TTP_TOKEN);
134         writePortMapping(input, OpenRoadmInterfacesImpl.TTP_TOKEN);
135         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
136             .setSuccess(true);
137         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
138             Mockito.any());
139         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
140         Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
141
142     }
143
144     @Test
145     public void serviceImplementationTerminationPointAsResourceTtp2() throws InterruptedException, ExecutionException {
146
147         ServiceImplementationRequestInput input = ServiceDataUtils
148             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.TTP_TOKEN);
149         writePortMapping(input, OpenRoadmInterfacesImpl.TTP_TOKEN);
150         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
151             .setSuccess(true);
152         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
153             Mockito.any());
154         Mockito.doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService)
155             .servicePowerSetup(Mockito.any());
156         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
157         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
158
159     }
160
161     @Test
162     public void serviceImplementationTerminationPointAsResourcePp() throws InterruptedException, ExecutionException {
163
164         ServiceImplementationRequestInput input = ServiceDataUtils
165             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.PP_TOKEN);
166         writePortMapping(input, OpenRoadmInterfacesImpl.PP_TOKEN);
167         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
168             .setSuccess(true);
169         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
170             Mockito.any());
171         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
172         Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
173
174     }
175
176     @Test
177     public void serviceImplementationTerminationPointAsResourceNetwork()
178         throws InterruptedException, ExecutionException {
179
180         ServiceImplementationRequestInput input = ServiceDataUtils
181             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
182         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
183         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
184             .setSuccess(true);
185         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
186             Mockito.any());
187         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
188         Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
189
190     }
191
192     @Test
193     public void serviceImplementationTerminationPointAsResourceClient()
194         throws InterruptedException, ExecutionException {
195
196         ServiceImplementationRequestInput input = ServiceDataUtils
197             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.CLIENT_TOKEN);
198         writePortMapping(input, OpenRoadmInterfacesImpl.CLIENT_TOKEN);
199         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
200         Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
201     }
202
203     @Test
204     public void serviceImplementationTerminationPointAsResourceNoMapping()
205         throws InterruptedException, ExecutionException {
206
207         String[] interfaceTokens = {
208             OpenRoadmInterfacesImpl.NETWORK_TOKEN,
209             OpenRoadmInterfacesImpl.CLIENT_TOKEN,
210             OpenRoadmInterfacesImpl.TTP_TOKEN,
211             OpenRoadmInterfacesImpl.PP_TOKEN
212         };
213
214         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("failed")
215             .setSuccess(false);
216         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
217             Mockito.any());
218
219         for (String tpToken : interfaceTokens) {
220             ServiceImplementationRequestInput input = ServiceDataUtils
221                 .buildServiceImplementationRequestInputTerminationPointResource(tpToken);
222             ServiceImplementationRequestOutput result =
223                 this.rendererServiceOperations.serviceImplementation(input).get();
224             Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
225                     result.getConfigurationResponseCommon().getResponseCode());
226         }
227     }
228
229     private void writePortMapping(ServiceImplementationRequestInput input, String tpToken) {
230         MountPointUtils.writeMapping(
231             input.getServiceAEnd().getNodeId(),
232             input.getServiceAEnd().getNodeId() + "-" + tpToken,
233             this.deviceTransactionManager
234         );
235         MountPointUtils.writeMapping(
236                 input.getServiceZEnd().getNodeId(),
237                 input.getServiceZEnd().getNodeId() + "-"
238                     + input.getServiceAEnd().getNodeId() + "-" + tpToken,
239                 this.deviceTransactionManager
240         );
241         MountPointUtils.writeMapping(
242                 input.getServiceAEnd().getNodeId(),
243                 input.getServiceAEnd().getNodeId() + "-"
244                     + input.getServiceZEnd().getNodeId() + "-" + tpToken,
245                 this.deviceTransactionManager
246         );
247         MountPointUtils.writeMapping(
248             input.getServiceZEnd().getNodeId(),
249             input.getServiceZEnd().getNodeId() + "-" + tpToken,
250             this.deviceTransactionManager
251         );
252     }
253
254     @Test
255     public void serviceImplementationRollbackAllNecessary() throws InterruptedException, ExecutionException {
256
257         ServiceImplementationRequestInput input = ServiceDataUtils
258             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
259         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
260         Mockito.doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService)
261             .servicePowerSetup(Mockito.any());
262         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
263         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
264
265     }
266
267     private GetPmInput createGetPmInput(String nodeId, String tp) {
268         GetPmInputBuilder getPmIpBldr = new GetPmInputBuilder();
269         getPmIpBldr.setNodeId(nodeId);
270         getPmIpBldr.setGranularity(PmGranularity._15min);
271         ResourceIdentifierBuilder rsrcBldr = new ResourceIdentifierBuilder();
272         rsrcBldr.setResourceName(tp + "-OTU");
273         getPmIpBldr.setResourceIdentifier(rsrcBldr.build());
274         getPmIpBldr.setResourceType(ResourceTypeEnum.Interface);
275         return getPmIpBldr.build();
276     }
277
278     @Test
279     public void serviceImplementationServiceInActive() throws InterruptedException, ExecutionException {
280
281         ServiceImplementationRequestInput input = ServiceDataUtils
282             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
283         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
284         Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks")
285             .setPmparameterValue("1").build();
286         List<Measurements> measurementsList = new ArrayList<Measurements>();
287         measurementsList.add(measurements);
288         GetPmOutput getPmOutput = new GetPmOutputBuilder()
289             .setNodeId("node1").setMeasurements(measurementsList).build();
290         Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
291             .getPm(Mockito.any());
292         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
293         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
294
295     }
296
297     @Test
298     public void serviceImplementationServiceInActive2() throws InterruptedException, ExecutionException {
299
300         ServiceImplementationRequestInput input = ServiceDataUtils
301             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
302         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
303         Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks")
304             .setPmparameterValue("1").build();
305         List<Measurements> measurementsList = new ArrayList<Measurements>();
306         measurementsList.add(measurements);
307         GetPmOutput getPmOutput = new GetPmOutputBuilder()
308             .setNodeId("node1").setMeasurements(measurementsList).build();
309         GetPmOutput getPmOutput2 = new GetPmOutputBuilder()
310             .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
311
312         Mockito.when(this.olmService.getPm(Mockito.any()))
313             .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
314         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
315         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
316
317     }
318
319     @Test
320     public void serviceImplementationServiceInActive3() throws InterruptedException, ExecutionException {
321
322         ServiceImplementationRequestInput input = ServiceDataUtils
323             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
324         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
325         Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks")
326             .setPmparameterValue("1").build();
327         List<Measurements> measurementsList = new ArrayList<Measurements>();
328         measurementsList.add(measurements);
329         GetPmOutput getPmOutput = new GetPmOutputBuilder()
330                 .setNodeId("node1").setMeasurements(measurementsList).build();
331         GetPmOutput getPmOutput2 = new GetPmOutputBuilder()
332                 .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
333
334         GetPmInput getPmInputZ = createGetPmInput("XPONDER-2-3",
335             OpenRoadmInterfacesImpl.NETWORK_TOKEN);
336         GetPmInput getPmInputA = createGetPmInput("XPONDER-1-2",
337             OpenRoadmInterfacesImpl.NETWORK_TOKEN);
338
339         Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputZ)))
340             .thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture());
341         Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputA)))
342             .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
343         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
344         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
345
346     }
347
348     @Test
349     public void serviceImplementationServiceActive() throws InterruptedException, ExecutionException {
350
351         ServiceImplementationRequestInput input = ServiceDataUtils
352             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
353         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
354         GetPmOutput getPmOutput = new GetPmOutputBuilder()
355             .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
356         GetPmOutput getPmOutput1 = null;
357         Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput1)
358             .buildFuture());
359         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
360             .setSuccess(true);
361         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
362             Mockito.any());
363         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
364         Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
365
366     }
367
368     @Test
369     public void serviceImplementationServiceActive2() throws InterruptedException, ExecutionException {
370
371         ServiceImplementationRequestInput input = ServiceDataUtils
372             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
373         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
374         GetPmOutput getPmOutput = new GetPmOutputBuilder().setMeasurements(new ArrayList<>()).build();
375         Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput)
376             .buildFuture());
377         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
378             .setSuccess(true);
379         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
380             Mockito.any());
381         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
382         Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
383
384     }
385
386     @Test
387     public void serviceImplementationServiceInActive4() throws InterruptedException, ExecutionException {
388
389         ServiceImplementationRequestInput input = ServiceDataUtils
390             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
391         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
392         Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors")
393             .setPmparameterValue("1").build();
394         List<Measurements> measurementsList = new ArrayList<Measurements>();
395         measurementsList.add(measurements);
396         GetPmOutput getPmOutput = new GetPmOutputBuilder()
397             .setNodeId("node1").setMeasurements(measurementsList).build();
398
399         Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
400             .getPm(Mockito.any());
401         ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
402             .setSuccess(true);
403         Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
404             Mockito.any());
405         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
406         Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
407
408     }
409
410     @Test
411     public void serviceImplementationServiceInActive5() throws InterruptedException, ExecutionException {
412
413         ServiceImplementationRequestInput input = ServiceDataUtils
414             .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
415         writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
416         Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors")
417             .setPmparameterValue("112000000000d").build();
418         List<Measurements> measurementsList = new ArrayList<Measurements>();
419         measurementsList.add(measurements);
420         GetPmOutput getPmOutput = new GetPmOutputBuilder()
421             .setNodeId("node1").setMeasurements(measurementsList).build();
422
423         Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
424             .getPm(Mockito.any());
425         ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
426         Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
427
428     }
429 }