ca5180547b0d033cd8c254f30267c9065f2e0f59
[transportpce.git] / olm / src / test / java / org / opendaylight / transportpce / olm / service / OlmPowerServiceImplTest.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
9 package org.opendaylight.transportpce.olm.service;
10
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.mockito.InjectMocks;
15 import org.mockito.Mockito;
16 import org.mockito.MockitoAnnotations;
17 import org.opendaylight.mdsal.binding.api.DataBroker;
18 import org.opendaylight.mdsal.binding.api.MountPoint;
19 import org.opendaylight.mdsal.binding.api.MountPointService;
20 import org.opendaylight.transportpce.common.NetworkUtils;
21 import org.opendaylight.transportpce.common.ResponseCodes;
22 import org.opendaylight.transportpce.common.StringConstants;
23 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
24 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
25 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl121;
26 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl221;
27 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
28 import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
29 import org.opendaylight.transportpce.common.mapping.MappingUtils;
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.PortMappingVersion221;
34 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
35 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
36 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl121;
37 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl221;
38 import org.opendaylight.transportpce.olm.power.PowerMgmt;
39 import org.opendaylight.transportpce.olm.power.PowerMgmtImpl;
40 import org.opendaylight.transportpce.olm.stub.MountPointServiceStub;
41 import org.opendaylight.transportpce.olm.stub.MountPointStub;
42 import org.opendaylight.transportpce.olm.util.OlmPowerServiceRpcImplUtil;
43 import org.opendaylight.transportpce.olm.util.OtsPmHolder;
44 import org.opendaylight.transportpce.olm.util.TransactionUtils;
45 import org.opendaylight.transportpce.test.AbstractTest;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseInput;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseOutput;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseOutputBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentInput;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentOutput;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutput;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerResetInput;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerResetOutput;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
57 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupOutput;
58 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupOutputBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownInput;
60 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownOutput;
61 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownOutputBuilder;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
66 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
67 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
70
71 public class OlmPowerServiceImplTest  extends AbstractTest {
72
73     private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceImplTest.class);
74     private MountPoint mountPoint;
75     private MountPointService mountPointService;
76     private DeviceTransactionManager deviceTransactionManager;
77     private CrossConnect crossConnect;
78     private OpenRoadmInterfaces openRoadmInterfaces;
79     private PortMapping portMapping;
80     private PowerMgmt powerMgmt;
81     private CrossConnectImpl121 crossConnectImpl121;
82     private CrossConnectImpl221 crossConnectImpl22;
83     private MappingUtils mappingUtils;
84     private OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121;
85     private OpenRoadmInterfacesImpl221 openRoadmInterfacesImpl22;
86     private PortMappingVersion221 portMappingVersion22;
87     private PortMappingVersion121 portMappingVersion121;
88     private OlmPowerService olmPowerService;
89     private DataBroker dataBroker;
90     private PowerMgmt powerMgmtMock;
91     @InjectMocks
92     private OlmPowerService olmPowerServiceMock;
93     private OtsPmHolder otsPmHolder;
94
95
96     @Before
97     public void setUp() {
98         this.mountPoint = new MountPointStub(this.getDataBroker());
99         this.mountPointService = new MountPointServiceStub(mountPoint);
100         this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
101         this.mappingUtils = Mockito.spy(MappingUtils.class);
102         Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(mappingUtils)
103                 .getOpenRoadmVersion(Mockito.anyString());
104         this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
105         this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager);
106         this.crossConnectImpl22 = new CrossConnectImpl221(deviceTransactionManager);
107         this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121,
108                 this.crossConnectImpl22);
109         this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
110         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl221(deviceTransactionManager);
111         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
112                 this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22);
113         this.portMappingVersion22 =
114                 new PortMappingVersion221(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
115         this.portMappingVersion121 =
116                 new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
117         this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion22, this.portMappingVersion121);
118         this.portMapping = Mockito.spy(this.portMapping);
119         this.powerMgmt = new PowerMgmtImpl(this.getDataBroker(), this.openRoadmInterfaces, this.crossConnect,
120             this.deviceTransactionManager);
121         this.olmPowerService = new OlmPowerServiceImpl(this.getDataBroker(), this.powerMgmt,
122             this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
123         this.dataBroker =  Mockito.mock(DataBroker.class);
124         this.powerMgmtMock = Mockito.mock(PowerMgmt.class);
125         this.olmPowerServiceMock = new OlmPowerServiceImpl(this.getDataBroker(), this.powerMgmtMock,
126             this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
127         this.olmPowerServiceMock = Mockito.mock(OlmPowerServiceImpl.class);
128         MockitoAnnotations.initMocks(this);
129     }
130
131     @Test
132     public void dummyTest() {
133         OlmPowerServiceImpl olmPowerServiceImpl = (OlmPowerServiceImpl) this.olmPowerService;
134         olmPowerServiceImpl.init();
135         olmPowerServiceImpl.close();
136     }
137
138
139     @Test
140     public void testGetPm() {
141         GetPmInput input = OlmPowerServiceRpcImplUtil.getGetPmInput();
142         GetPmOutput output = this.olmPowerService.getPm(input);
143         Assert.assertEquals(new GetPmOutputBuilder().build(), output);
144         Assert.assertEquals(null, output.getResourceId());
145     }
146
147     @Test
148     public void testServicePowerSetupSuccess() {
149         ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
150         Mockito.when(this.powerMgmtMock.setPower(Mockito.any())).thenReturn(true);
151         //TODO
152         Mockito.when(this.olmPowerServiceMock.servicePowerSetup(Mockito.any()))
153                 .thenReturn(new ServicePowerSetupOutputBuilder().setResult("Success").build());
154         ServicePowerSetupOutput output = this.olmPowerServiceMock.servicePowerSetup(input);
155         Assert.assertEquals(new ServicePowerSetupOutputBuilder().setResult("Success").build(), output);
156         Assert.assertEquals("Success", output.getResult());
157     }
158
159     @Test
160     public void testServicePowerSetupFailed() {
161         ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
162         Mockito.when(this.powerMgmtMock.setPower(Mockito.any())).thenReturn(false);
163         //TODO
164         Mockito.when(this.olmPowerServiceMock.servicePowerSetup(Mockito.any()))
165                 .thenReturn(new ServicePowerSetupOutputBuilder().setResult("Failed").build());
166         ServicePowerSetupOutput output = this.olmPowerServiceMock.servicePowerSetup(input);
167         Assert.assertEquals("Failed", output.getResult());
168     }
169
170     @Test
171     public void testServicePowerTurnDownSuccess() {
172         ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput();
173         Mockito.when(this.powerMgmtMock.powerTurnDown(Mockito.any())).thenReturn(true);
174         //TODO
175         Mockito.when(this.olmPowerServiceMock.servicePowerTurndown(Mockito.any()))
176                 .thenReturn(new ServicePowerTurndownOutputBuilder().setResult("Success").build());
177         ServicePowerTurndownOutput output = this.olmPowerServiceMock.servicePowerTurndown(input);
178         Assert.assertEquals(new ServicePowerTurndownOutputBuilder().setResult("Success").build(), output);
179         Assert.assertEquals("Success", output.getResult());
180     }
181
182     @Test
183     public void testServicePowerTurnDownFailed() {
184         ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput();
185         Mockito.when(this.powerMgmtMock.powerTurnDown(Mockito.any())).thenReturn(false);
186         //TODO
187         Mockito.when(this.olmPowerServiceMock.servicePowerTurndown(Mockito.any()))
188                 .thenReturn(new ServicePowerTurndownOutputBuilder().setResult("Failed").build());
189         ServicePowerTurndownOutput output = this.olmPowerServiceMock.servicePowerTurndown(input);
190         Assert.assertEquals(new ServicePowerTurndownOutputBuilder().setResult("Failed").build(), output);
191         Assert.assertEquals("Failed", output.getResult());
192     }
193
194     /*
195     @Test
196     public void testCalculateSpanlossBase() {
197         CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput();
198         //TODO
199         Mockito.when(this.olmPowerServiceMock.calculateSpanlossBase(Mockito.any()))
200                 .thenReturn(new CalculateSpanlossBaseOutputBuilder().setResult("Failed").build());
201         CalculateSpanlossBaseOutput output = this.olmPowerServiceMock.calculateSpanlossBase(input);
202         Assert.assertEquals("Failed", output.getResult());
203
204     }
205     */
206
207     /*
208     @Test
209     public void testCalculateSpanlossBase2() {
210         NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
211 <<<<<<< HEAD
212         InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
213             .child(Network.class, overlayTopologyKey)
214 =======
215         InstanceIdentifier<Network1> networkTopoIID = InstanceIdentifier.builder(Networks.class)
216                 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
217                                 .ietf.network.rev180226.networks.Network.class,
218                         overlayTopologyKey)
219 >>>>>>> 87d8bf0... Retrieve OLM modifs from change 80051
220             .augmentation(Network1.class)
221             .build();
222         InstanceIdentifier<Network> networkIID = InstanceIdentifier.builder(Networks.class)
223                 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
224                                 .ietf.network.rev180226.networks.Network.class,
225                         overlayTopologyKey)
226                 .build();
227         Network1 network = TransactionUtils.getNetwork();
228         Network ietfNetwork = TransactionUtils.getOverLayNetwork();
229         TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, ietfNetwork);
230         TransactionUtils.writeTransaction(this.getDataBroker(), networkTopoIID, network);
231         try {
232             Thread.sleep(1000);
233         } catch (InterruptedException e) {
234             LOG.error("Write transaction failed !",e);
235         }
236         CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput();
237         //TODO
238         Mockito.when(this.olmPowerServiceMock.calculateSpanlossBase(Mockito.any()))
239                 .thenReturn(new CalculateSpanlossBaseOutputBuilder().setResult("Failed").build());
240         CalculateSpanlossBaseOutput output = this.olmPowerServiceMock.calculateSpanlossBase(input);
241         Assert.assertEquals("Failed", output.getResult());
242
243     }
244     */
245     @Test
246     public void testCalculateSpanlossBase3() {
247         NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
248         InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
249             .child(Network.class, overlayTopologyKey)
250             .augmentation(Network1.class)
251             .build();
252         Network1 network = TransactionUtils.getNetwork();
253         TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
254         try {
255             Thread.sleep(1000);
256         } catch (InterruptedException e) {
257             LOG.error("Write transaction failed !",e);
258         }
259         CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput2();
260         //TODO
261         Mockito.when(this.olmPowerServiceMock.calculateSpanlossBase(Mockito.any()))
262                 .thenReturn(new CalculateSpanlossBaseOutputBuilder().setResult("Failed").build());
263         CalculateSpanlossBaseOutput output = this.olmPowerServiceMock.calculateSpanlossBase(input);
264         Assert.assertEquals("Failed", output.getResult());
265
266     }
267
268
269     @Test
270     public void testCalculateSpanlossBase4() {
271         NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
272         InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
273             .child(Network.class, overlayTopologyKey)
274             .augmentation(Network1.class)
275             .build();
276         Network1 network = TransactionUtils.getEmptyNetwork();
277         TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
278         try {
279             Thread.sleep(1000);
280         } catch (InterruptedException e) {
281             LOG.error("Write transaction failed !",e);
282         }
283         CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput2();
284         CalculateSpanlossBaseOutput output = this.olmPowerService.calculateSpanlossBase(input);
285         Assert.assertEquals("Failed", output.getResult());
286
287     }
288
289     @Test
290     public void testCalculateSpanlossBase5() {
291         NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
292         InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
293             .child(Network.class, overlayTopologyKey)
294             .augmentation(Network1.class)
295             .build();
296         Network1 network = TransactionUtils.getNullNetwork();
297         TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
298         try {
299             Thread.sleep(1000);
300         } catch (InterruptedException e) {
301             LOG.error("Write transaction failed !",e);
302         }
303         CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput2();
304         CalculateSpanlossBaseOutput output = this.olmPowerService.calculateSpanlossBase(input);
305         Assert.assertEquals("Failed", output.getResult());
306
307     }
308
309 //    @Test
310 //    public void testCalculateSpanlossBase4() throws InterruptedException {
311 //        NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
312 //        InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Network.class, overlayTopologyKey)
313 //            .augmentation(Network1.class)
314 //            .build();
315 //        Network1 network = TransactionUtils.getNetwork2();
316 //        TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
317 //
318 //        Thread.sleep(500);
319 //
320 //        List<NodeId> nodes = TransactionUtils.getNodes();
321 //        Node n;
322 //        SupportingNode sn;
323 //
324 //        List<SupportingNode> snl;
325 //        NodeId n5 = new NodeId("node 5");
326 //        KeyedInstanceIdentifier<Node, NodeKey> mappedNodeII2 =
327 //            InstanceIdentifiers.UNDERLAY_NETWORK_II.child(Node.class, new NodeKey(n5));
328 //
329 //        sn = new SupportingNodeBuilder().setNetworkRef(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))
330 //            .setNodeRef(n5).build();
331 //        snl = new ArrayList<>();
332 //        snl.add(sn);
333 //        n = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608
334 //            .network.NodeBuilder().setNodeId(n5).build();
335 //        TransactionUtils.writeTransaction(this.getDataBroker(), mappedNodeII2, n);
336 //        Thread.sleep(500);
337 //
338 //        for(int i=0; i < nodes.size(); i++) {
339 //            KeyedInstanceIdentifier<Node, NodeKey> mappedNodeII =
340 //                InstanceIdentifiers.OVERLAY_NETWORK_II.child(Node.class, new NodeKey(nodes.get(i)));
341 //            if (i != 0){
342 //                sn = new SupportingNodeBuilder().setNetworkRef(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))
343 //                    .setNodeRef(nodes.get(i-1)).build();
344 //            }else {
345 //                sn = new SupportingNodeBuilder().setNodeRef(n5).build();
346 //            }
347 //            snl = new ArrayList<>();
348 //            snl.add(sn);
349 //            n = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608
350 //                .network.NodeBuilder().setNodeId(nodes.get(i)).setSupportingNode(snl).build();
351 //            TransactionUtils.writeTransaction(this.getDataBroker(), mappedNodeII, n);
352 //            Thread.sleep(500);
353 //        }
354 //
355 //        Thread.sleep(1000);
356 //
357 //        CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput2();
358 //        CalculateSpanlossBaseOutput output = this.olmPowerService.calculateSpanlossBase(input);
359 //        Assert.assertEquals("Failed", output.getResult());
360 //
361 //    }
362
363     @Test
364     public void testCalculateSpanlossCurrent1() {
365         CalculateSpanlossCurrentInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossCurrentInput();
366         CalculateSpanlossCurrentOutput output = this.olmPowerService.calculateSpanlossCurrent(input);
367         Assert.assertEquals(null, output);
368     }
369
370     @Test
371     public void testCalculateSpanlossCurrent2() {
372         NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
373         InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
374             .child(Network.class, overlayTopologyKey)
375             .augmentation(Network1.class)
376             .build();
377         Network1 network = TransactionUtils.getNetwork();
378         TransactionUtils.writeTransaction(this.getDataBroker(), networkIID, network);
379         try {
380             Thread.sleep(1000);
381         } catch (InterruptedException e) {
382             LOG.error("Write transaction failed !",e);
383         }
384         CalculateSpanlossCurrentInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossCurrentInput();
385         CalculateSpanlossCurrentOutput output = this.olmPowerService.calculateSpanlossCurrent(input);
386         Assert.assertEquals(null, output);
387     }
388
389     @Test
390     public void testServicePowerReset() {
391         ServicePowerResetInput input = OlmPowerServiceRpcImplUtil.getServicePowerResetInput();
392         ServicePowerResetOutput output = this.olmPowerService.servicePowerReset(input);
393         Assert.assertEquals(null, output);
394     }
395
396     @Test
397     public void testServicePowerTurndownSuccessResult() {
398         ServicePowerTurndownInput servicePowerTurndownInput = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput();
399         ServicePowerTurndownOutput servicePowerTurndownOutput =
400                 this.olmPowerService.servicePowerTurndown(servicePowerTurndownInput);
401         Assert.assertEquals(ResponseCodes.SUCCESS_RESULT, servicePowerTurndownOutput.getResult());
402     }
403
404     @Test
405     public void testServicePowerTurndownFailResult() {
406         ServicePowerTurndownInput servicePowerTurndownInput =
407                 OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput2();
408         ServicePowerTurndownOutput servicePowerTurndownOutput =
409                 this.olmPowerService.servicePowerTurndown(servicePowerTurndownInput);
410         Assert.assertEquals(ResponseCodes.FAILED_RESULT, servicePowerTurndownOutput.getResult());
411     }
412
413     @Test
414     public void testServicePowerSetupSuccessResult() {
415         ServicePowerSetupInput servicePowerSetupInput =
416                 OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
417         ServicePowerSetupOutput servicePowerSetupOutput =
418                 this.olmPowerService.servicePowerSetup(servicePowerSetupInput);
419         Assert.assertEquals(ResponseCodes.SUCCESS_RESULT, servicePowerSetupOutput.getResult());
420     }
421
422     @Test
423     public void testServicePowerSetupFailResult() {
424         ServicePowerSetupInput servicePowerSetupInput = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
425         Mockito.when(powerMgmtMock.setPower(servicePowerSetupInput)).thenReturn(Boolean.FALSE);
426         OlmPowerService olmPowerServiceWithMock = new OlmPowerServiceImpl(dataBroker, powerMgmtMock,
427                 this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
428         ServicePowerSetupOutput servicePowerSetupOutput =
429                 olmPowerServiceWithMock.servicePowerSetup(servicePowerSetupInput);
430         Assert.assertEquals(ResponseCodes.FAILED_RESULT, servicePowerSetupOutput.getResult());
431     }
432 }