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