package org.opendaylight.transportpce.olm.power;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.transportpce.olm.util.OlmUtils;
import org.opendaylight.transportpce.test.AbstractTest;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.OpenroadmNodeVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.OpenroadmNodeVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.nodes.NodeInfoBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.OpticalControlMode;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RatioDB;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.ots.container.OtsBuilder;
import org.opendaylight.yangtools.yang.common.Decimal64;
-@Ignore
+@Disabled
public class PowerMgmtPowerMockTest extends AbstractTest {
private MountPoint mountPoint;
private PortMappingVersion221 portMappingVersion22;
private PortMappingVersion121 portMappingVersion121;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
this.mountPoint = new MountPointStub(getDataBroker());
this.mountPointService = new MountPointServiceStub(mountPoint);
this.mappingUtils = new MappingUtilsImpl(getDataBroker());
this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion710,
this.portMappingVersion22, this.portMappingVersion121);
this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
- this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl221(deviceTransactionManager, this.portMapping,
- this.portMappingVersion22);
- this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager, this.portMapping,
- this.portMappingVersion710);
+ this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl221(deviceTransactionManager, this.portMapping);
+ this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager, this.portMapping);
this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22,
this.openRoadmInterfacesImpl710);
this.openRoadmInterfaces = Mockito.spy(this.openRoadmInterfaces);
this.portMapping = Mockito.spy(this.portMapping);
- this.powerMgmt = new PowerMgmtImpl(getDataBroker(), this.openRoadmInterfaces, this.crossConnect,
- this.deviceTransactionManager, this.portMapping);
+ this.powerMgmt = new PowerMgmtImpl(this.openRoadmInterfaces, this.crossConnect,
+ this.deviceTransactionManager, this.portMapping, 1000, 1000);
}
@Test
- public void testSetPowerMockingUtil() {
+ void testSetPowerMockingUtil() {
Mockito.mockStatic(OlmUtils.class);
Mockito.when(this.portMapping.getNode(Mockito.anyString()))
.thenReturn(getXpdrNodesFromNodesBuilderDeg());
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput2();
boolean output = this.powerMgmt.setPower(input);
- Assert.assertEquals(false, output);
+ assertEquals(false, output);
}
@Test
- public void testSetPowerMockingUtilNetwokType() throws OpenRoadmInterfaceException {
+ void testSetPowerMockingUtilNetwokType() throws OpenRoadmInterfaceException {
Mockito.mockStatic(OlmUtils.class);
Mockito.mockStatic(PowerMgmtVersion121.class);
Mockito.when(this.portMapping.getNode(Mockito.anyString()))
.thenReturn(Optional.empty());
PowerMgmtImpl powerMgmtImpl = getNewPowerMgmt(openRoadmInterfacesImpl121Spy,this.crossConnect);
boolean output = powerMgmtImpl.setPower(input);
- Assert.assertEquals(true, output);
+ assertEquals(true, output);
}
@Test
- public void testSetPowerMockingUtilNetwokTypeMoreThanOneNode() throws OpenRoadmInterfaceException {
+ void testSetPowerMockingUtilNetwokTypeMoreThanOneNode() throws OpenRoadmInterfaceException {
Mockito.mockStatic(OlmUtils.class);
Mockito.mockStatic(PowerMgmtVersion121.class);
Mockito.when(this.portMapping.getNode(Mockito.anyString()))
.thenReturn(Optional.empty());
PowerMgmtImpl powerMgmtImpl = getNewPowerMgmt(openRoadmInterfacesImpl121Spy,this.crossConnect);
boolean output = powerMgmtImpl.setPower(input);
- Assert.assertEquals(true, output);
+ assertEquals(true, output);
}
@Test
- public void testSetPowerXpdrNodes() {
+ void testSetPowerXpdrNodes() {
Mockito.mockStatic(OlmUtils.class);
Mockito.when(this.portMapping.getNode(Mockito.anyString()))
.thenReturn(getXpdrNodesFromNodesBuilderDeg());
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput3();
boolean output = this.powerMgmt.setPower(input);
- Assert.assertEquals(true, output);
+ assertEquals(true, output);
}
@Test
- public void testSetPowerRdmNodesReturnInterfaceEmpty() throws OpenRoadmInterfaceException {
+ void testSetPowerRdmNodesReturnInterfaceEmpty() throws OpenRoadmInterfaceException {
Mockito.mockStatic(OlmUtils.class);
Mockito.when(this.portMapping.getNode(Mockito.anyString()))
.thenReturn(getRdmNodesFromNodesBuilder());
.thenReturn(Optional.empty());
PowerMgmtImpl powerMgmtImpl = getNewPowerMgmt(openRoadmInterfacesImpl121Spy,this.crossConnect);
boolean output = powerMgmtImpl.setPower(input);
- Assert.assertEquals(false, output);
+ assertEquals(false, output);
}
@Test
- public void testSetPowerRdmNodesThrowsException() throws OpenRoadmInterfaceException {
+ void testSetPowerRdmNodesThrowsException() throws OpenRoadmInterfaceException {
Mockito.mockStatic(OlmUtils.class);
Mockito.when(this.portMapping.getNode(Mockito.anyString()))
.thenReturn(getRdmNodesFromNodesBuilder());
.thenThrow(new OpenRoadmInterfaceException("error thrown by unit tests "));
PowerMgmtImpl powerMgmtImpl = getNewPowerMgmt(openRoadmInterfacesImpl121Spy,this.crossConnect);
boolean output = powerMgmtImpl.setPower(input);
- Assert.assertEquals(false, output);
+ assertEquals(false, output);
}
@Test
- public void testSetPowerRdmNodesReturnInterface() throws OpenRoadmInterfaceException {
+ void testSetPowerRdmNodesReturnInterface() throws OpenRoadmInterfaceException {
Mockito.mockStatic(OlmUtils.class);
Mockito.when(this.portMapping.getNode(Mockito.anyString()))
.thenReturn(getRdmNodesFromNodesBuilder());
Mockito.anyString())).thenReturn(true);
PowerMgmtImpl powerMgmtImpl = getNewPowerMgmt(openRoadmInterfacesImpl121Spy,crossConnectMock);
boolean output = powerMgmtImpl.setPower(input);
- Assert.assertEquals(true, output);
+ assertEquals(true, output);
}
private PowerMgmtImpl getNewPowerMgmt(OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121Spy,
this.mappingUtils, openRoadmInterfacesImpl121Spy, this.openRoadmInterfacesImpl22,
this.openRoadmInterfacesImpl710);
openRoadmInterfacesSpy = Mockito.spy(openRoadmInterfacesSpy);
- return new PowerMgmtImpl(getDataBroker(), openRoadmInterfacesSpy, crossConnectMock,
- this.deviceTransactionManager, this.portMapping);
+ return new PowerMgmtImpl(openRoadmInterfacesSpy, crossConnectMock,
+ this.deviceTransactionManager, this.portMapping, 0, 0);
}
private Nodes getXpdrNodesFromNodesBuilderDeg() {