import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.mdsal.binding.api.MountPoint;
+import org.opendaylight.mdsal.binding.api.MountPointService;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl221;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
-import org.opendaylight.transportpce.common.mapping.*;
+import org.opendaylight.transportpce.common.mapping.MappingUtils;
+import org.opendaylight.transportpce.common.mapping.MappingUtilsImpl;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
+import org.opendaylight.transportpce.common.mapping.PortMappingVersion121;
+import org.opendaylight.transportpce.common.mapping.PortMappingVersion221;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl121;
import org.opendaylight.transportpce.olm.util.TransactionUtils;
import org.opendaylight.transportpce.test.AbstractTest;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownInput;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
public class PowerMgmtTest extends AbstractTest {
public void setUp() {
this.mountPoint = new MountPointStub(this.getDataBroker());
this.mountPointService = new MountPointServiceStub(mountPoint);
- this.mappingUtils = new MappingUtilsImpl(getDataBroker());
- this.mappingUtils = Mockito.spy(MappingUtils.class);
+ // this.mappingUtils = new MappingUtilsImpl(getDataBroker());
+ this.mappingUtils = Mockito.spy(new MappingUtilsImpl(getDataBroker()));
Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(mappingUtils)
.getOpenRoadmVersion(Mockito.anyString());
this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
new PortMappingVersion221(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
this.portMappingVersion121 =
new PortMappingVersion121(getDataBroker(), deviceTransactionManager, this.openRoadmInterfaces);
- this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion22, this.mappingUtils,
- this.portMappingVersion121);
+ this.portMapping = new PortMappingImpl(getDataBroker(),
+ this.portMappingVersion22, this.portMappingVersion121);
this.portMapping = Mockito.spy(this.portMapping);
this.powerMgmt = new PowerMgmtImpl(this.getDataBroker(), this.openRoadmInterfaces, this.crossConnect,
- this.deviceTransactionManager);
+ this.deviceTransactionManager);
}
@Test
public void testSetPower() {
-
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
boolean output = this.powerMgmt.setPower(input);
Assert.assertEquals(true, output);
-
}
@Test
public void testSetPower2() {
-
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput2();
boolean output = this.powerMgmt.setPower(input);
Assert.assertEquals(true, output);
-
}
@Test
public void testSetPower3() {
-
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput3();
boolean output = this.powerMgmt.setPower(input);
Assert.assertEquals(true, output);
-
}
@Test
public void testSetPower4() {
-
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput4();
boolean output = this.powerMgmt.setPower(input);
Assert.assertEquals(true, output);
+ }
+ @Test
+ public void testPowerTurnDown() {
+ ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput();
+ boolean output = this.powerMgmt.powerTurnDown(input);
+ Assert.assertEquals(true, output);
+ }
+
+ @Test
+ public void testPowerTurnDown2() {
+ ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput2();
+ boolean output = this.powerMgmt.powerTurnDown(input);
+ Assert.assertEquals(false, output);
+ }
+
+ @Test
+ public void testPowerTurnDown3() {
+ ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput3();
+ boolean output = this.powerMgmt.powerTurnDown(input);
+ Assert.assertEquals(true, output);
+ }
+
+ @Test
+ public void testPowerTurnDown4() {
+ ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput4();
+ boolean output = this.powerMgmt.powerTurnDown(input);
+ Assert.assertEquals(false, output);
}
@Test
List<NodeId> nodes = TransactionUtils.getNodeIds();
for (NodeId nodeId : nodes) {
TransactionUtils.writeNodeTransaction(nodeId.getValue(), this.getDataBroker(), null);
- Thread.sleep(500);
+ Thread.sleep(1000);
}
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
boolean output = this.powerMgmt.setPower(input);