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