package org.opendaylight.transportpce.olm.service;
+import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
-import org.mockito.InjectMocks;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.MountPoint;
-import org.opendaylight.mdsal.binding.api.MountPointService;
-import org.opendaylight.transportpce.common.NetworkUtils;
-import org.opendaylight.transportpce.common.ResponseCodes;
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.CrossConnectImpl121;
-import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl221;
-import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl710;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
-import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
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.mapping.PortMappingVersion710;
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.common.openroadminterfaces.OpenRoadmInterfacesImpl221;
-import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl710;
import org.opendaylight.transportpce.olm.power.PowerMgmt;
import org.opendaylight.transportpce.olm.power.PowerMgmtImpl;
-import org.opendaylight.transportpce.olm.stub.MountPointServiceStub;
-import org.opendaylight.transportpce.olm.stub.MountPointStub;
import org.opendaylight.transportpce.olm.util.OlmPowerServiceRpcImplUtil;
-import org.opendaylight.transportpce.olm.util.TransactionUtils;
import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerResetInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerResetOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmNamesEnum;
-@Ignore
public class OlmPowerServiceImplTest extends AbstractTest {
- private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceImplTest.class);
- private MountPoint mountPoint;
- private MountPointService mountPointService;
private DeviceTransactionManager deviceTransactionManager;
- private CrossConnect crossConnect;
private OpenRoadmInterfaces openRoadmInterfaces;
private PortMapping portMapping;
private PowerMgmt powerMgmt;
- private CrossConnectImpl121 crossConnectImpl121;
- private CrossConnectImpl221 crossConnectImpl22;
- private CrossConnectImpl710 crossConnectImpl710;
private MappingUtils mappingUtils;
- private OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121;
- private OpenRoadmInterfacesImpl221 openRoadmInterfacesImpl22;
- private OpenRoadmInterfacesImpl710 openRoadmInterfacesImpl710;
- private PortMappingVersion710 portMappingVersion710;
- private PortMappingVersion221 portMappingVersion22;
- private PortMappingVersion121 portMappingVersion121;
private OlmPowerService olmPowerService;
private DataBroker dataBroker;
- private PowerMgmt powerMgmtMock;
- @InjectMocks
- private OlmPowerService olmPowerServiceMock;
-
@Before
public void setUp() {
- this.dataBroker = getNewDataBroker();
- this.mountPoint = new MountPointStub(this.dataBroker);
- this.mountPointService = new MountPointServiceStub(mountPoint);
- this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
- this.mappingUtils = Mockito.spy(new MappingUtilsImpl(dataBroker));
- Mockito.doReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1).when(mappingUtils)
- .getOpenRoadmVersion(Mockito.anyString());
- this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
- this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager);
- this.crossConnectImpl22 = new CrossConnectImpl221(deviceTransactionManager);
- this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121,
- this.crossConnectImpl22, this.crossConnectImpl710);
- this.portMappingVersion22 = new PortMappingVersion221(dataBroker, deviceTransactionManager);
- this.portMappingVersion121 = new PortMappingVersion121(dataBroker, deviceTransactionManager);
- this.portMappingVersion710 = new PortMappingVersion710(dataBroker, deviceTransactionManager);
- this.portMapping = new PortMappingImpl(dataBroker, 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.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
- this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22,
- this.openRoadmInterfacesImpl710);
- this.portMapping = Mockito.spy(this.portMapping);
- this.powerMgmt = new PowerMgmtImpl(this.dataBroker, this.openRoadmInterfaces, this.crossConnect,
- this.deviceTransactionManager, this.portMapping);
+ this.dataBroker = Mockito.mock(DataBroker.class);
+ this.powerMgmt = Mockito.mock(PowerMgmtImpl.class);
+ this.deviceTransactionManager = Mockito.mock(DeviceTransactionManager.class);
+ this.portMapping = Mockito.mock(PortMapping.class);
+ this.mappingUtils = Mockito.mock(MappingUtils.class);
+ this.openRoadmInterfaces = Mockito.mock(OpenRoadmInterfaces.class);
this.olmPowerService = new OlmPowerServiceImpl(this.dataBroker, this.powerMgmt,
- this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
- this.powerMgmtMock = Mockito.mock(PowerMgmtImpl.class);
- this.olmPowerServiceMock = new OlmPowerServiceImpl(this.dataBroker, this.powerMgmtMock,
- this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
- this.olmPowerServiceMock = Mockito.mock(OlmPowerServiceImpl.class);
- MockitoAnnotations.openMocks(this);
+ this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
}
@Test
olmPowerServiceImpl.close();
}
-
@Test
public void testGetPm() {
+ Mockito.when(this.mappingUtils.getOpenRoadmVersion(Mockito.anyString()))
+ .thenReturn(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1);
+ Mockito.when(this.deviceTransactionManager.getDataFromDevice(Mockito.anyString(), Mockito.any(),
+ Mockito.any(), Mockito.anyLong(), Mockito.any()))
+ .thenReturn(Optional.of(OlmPowerServiceRpcImplUtil.getCurrentPmList121()));
+
GetPmInput input = OlmPowerServiceRpcImplUtil.getGetPmInput();
- GetPmOutput output = this.olmPowerService.getPm(input);
- Assert.assertEquals(new GetPmOutputBuilder().build(), output);
- Assert.assertEquals(null, output.getResourceId());
+ GetPmOutput result = this.olmPowerService.getPm(input);
+ Assert.assertEquals(
+ org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.PmGranularity._15min,
+ result.getGranularity());
+ Assert.assertEquals(PmNamesEnum.OpticalPowerInput.toString(),
+ result.getMeasurements().stream().findFirst().get().getPmparameterName());
+ Assert.assertEquals(String.valueOf(3.0),
+ result.getMeasurements().stream().findFirst().get().getPmparameterValue());
+ Assert.assertEquals("ots-deg1",
+ result.getResourceIdentifier().getResourceName());
}
@Test
public void testServicePowerSetupSuccess() {
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
- Mockito.when(this.powerMgmtMock.setPower(Mockito.any())).thenReturn(true);
- //TODO
- Mockito.when(this.olmPowerServiceMock.servicePowerSetup(Mockito.any()))
- .thenReturn(new ServicePowerSetupOutputBuilder().setResult("Success").build());
- ServicePowerSetupOutput output = this.olmPowerServiceMock.servicePowerSetup(input);
- Assert.assertEquals(new ServicePowerSetupOutputBuilder().setResult("Success").build(), output);
- Assert.assertEquals("Success", output.getResult());
+ Mockito.when(this.powerMgmt.setPower(Mockito.any())).thenReturn(true);
+ ServicePowerSetupOutput result = this.olmPowerService.servicePowerSetup(input);
+ Assert.assertEquals(new ServicePowerSetupOutputBuilder().setResult("Success").build(), result);
+ Assert.assertEquals("Success", result.getResult());
}
@Test
public void testServicePowerSetupFailed() {
ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
- Mockito.when(this.powerMgmtMock.setPower(Mockito.any())).thenReturn(false);
- //TODO
- Mockito.when(this.olmPowerServiceMock.servicePowerSetup(Mockito.any()))
- .thenReturn(new ServicePowerSetupOutputBuilder().setResult("Failed").build());
- ServicePowerSetupOutput output = this.olmPowerServiceMock.servicePowerSetup(input);
+ Mockito.when(this.powerMgmt.setPower(Mockito.any())).thenReturn(false);
+ ServicePowerSetupOutput output = this.olmPowerService.servicePowerSetup(input);
Assert.assertEquals("Failed", output.getResult());
}
@Test
public void testServicePowerTurnDownSuccess() {
ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput();
- Mockito.when(this.powerMgmtMock.powerTurnDown(Mockito.any())).thenReturn(true);
- //TODO
- Mockito.when(this.olmPowerServiceMock.servicePowerTurndown(Mockito.any()))
- .thenReturn(new ServicePowerTurndownOutputBuilder().setResult("Success").build());
- ServicePowerTurndownOutput output = this.olmPowerServiceMock.servicePowerTurndown(input);
+ Mockito.when(this.powerMgmt.powerTurnDown(Mockito.any())).thenReturn(true);
+ ServicePowerTurndownOutput output = this.olmPowerService.servicePowerTurndown(input);
Assert.assertEquals(new ServicePowerTurndownOutputBuilder().setResult("Success").build(), output);
Assert.assertEquals("Success", output.getResult());
}
@Test
public void testServicePowerTurnDownFailed() {
ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput();
- Mockito.when(this.powerMgmtMock.powerTurnDown(Mockito.any())).thenReturn(false);
- //TODO
- Mockito.when(this.olmPowerServiceMock.servicePowerTurndown(Mockito.any()))
- .thenReturn(new ServicePowerTurndownOutputBuilder().setResult("Failed").build());
- ServicePowerTurndownOutput output = this.olmPowerServiceMock.servicePowerTurndown(input);
+ Mockito.when(this.powerMgmt.powerTurnDown(Mockito.any())).thenReturn(false);
+ ServicePowerTurndownOutput output = this.olmPowerService.servicePowerTurndown(input);
Assert.assertEquals(new ServicePowerTurndownOutputBuilder().setResult("Failed").build(), output);
Assert.assertEquals("Failed", output.getResult());
}
- @Test
- public void testCalculateSpanlossBase3() {
- NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
- InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
- .child(Network.class, overlayTopologyKey)
- .augmentation(Network1.class)
- .build();
- Network1 network = TransactionUtils.getNetwork();
- TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- LOG.error("Write transaction failed !",e);
- }
- CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput2();
- //TODO
- Mockito.when(this.olmPowerServiceMock.calculateSpanlossBase(Mockito.any()))
- .thenReturn(new CalculateSpanlossBaseOutputBuilder().setResult("Failed").build());
- CalculateSpanlossBaseOutput output = this.olmPowerServiceMock.calculateSpanlossBase(input);
- Assert.assertEquals("Failed", output.getResult());
-
- }
-
-
- @Test
- public void testCalculateSpanlossBase4() {
- NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
- InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
- .child(Network.class, overlayTopologyKey)
- .augmentation(Network1.class)
- .build();
- Network1 network = TransactionUtils.getEmptyNetwork();
- TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- LOG.error("Write transaction failed !",e);
- }
- CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput2();
- CalculateSpanlossBaseOutput output = this.olmPowerService.calculateSpanlossBase(input);
- Assert.assertEquals("Failed", output.getResult());
-
- }
-
- @Test
- public void testCalculateSpanlossBase5() {
- NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
- InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
- .child(Network.class, overlayTopologyKey)
- .augmentation(Network1.class)
- .build();
- Network1 network = TransactionUtils.getNullNetwork();
- TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- LOG.error("Write transaction failed !",e);
- }
- CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput2();
- CalculateSpanlossBaseOutput output = this.olmPowerService.calculateSpanlossBase(input);
- Assert.assertEquals("Failed", output.getResult());
-
- }
-
- @Test
- public void testCalculateSpanlossCurrent1() {
- CalculateSpanlossCurrentInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossCurrentInput();
- CalculateSpanlossCurrentOutput output = this.olmPowerService.calculateSpanlossCurrent(input);
- Assert.assertEquals(null, output);
- }
-
- @Test
- public void testCalculateSpanlossCurrent2() {
- NetworkKey overlayTopologyKey = new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID));
- InstanceIdentifier<Network1> networkIID = InstanceIdentifier.builder(Networks.class)
- .child(Network.class, overlayTopologyKey)
- .augmentation(Network1.class)
- .build();
- Network1 network = TransactionUtils.getNetwork();
- TransactionUtils.writeTransaction(this.dataBroker, networkIID, network);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- LOG.error("Write transaction failed !",e);
- }
- CalculateSpanlossCurrentInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossCurrentInput();
- CalculateSpanlossCurrentOutput output = this.olmPowerService.calculateSpanlossCurrent(input);
- Assert.assertEquals(null, output);
- }
-
@Test
public void testServicePowerReset() {
ServicePowerResetInput input = OlmPowerServiceRpcImplUtil.getServicePowerResetInput();
ServicePowerResetOutput output = this.olmPowerService.servicePowerReset(input);
Assert.assertEquals(null, output);
}
-
- @Test
- public void testServicePowerTurndownSuccessResult() {
- ServicePowerTurndownInput servicePowerTurndownInput = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput();
- ServicePowerTurndownOutput servicePowerTurndownOutput =
- this.olmPowerService.servicePowerTurndown(servicePowerTurndownInput);
- Assert.assertEquals(ResponseCodes.SUCCESS_RESULT, servicePowerTurndownOutput.getResult());
- }
-
- @Test
- public void testServicePowerTurndownFailResult() {
- ServicePowerTurndownInput servicePowerTurndownInput =
- OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput2();
- ServicePowerTurndownOutput servicePowerTurndownOutput =
- this.olmPowerService.servicePowerTurndown(servicePowerTurndownInput);
- Assert.assertEquals(ResponseCodes.FAILED_RESULT, servicePowerTurndownOutput.getResult());
- }
-
- @Test
- public void testServicePowerSetupSuccessResult() {
- ServicePowerSetupInput servicePowerSetupInput =
- OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
- ServicePowerSetupOutput servicePowerSetupOutput =
- this.olmPowerService.servicePowerSetup(servicePowerSetupInput);
- Assert.assertEquals(ResponseCodes.SUCCESS_RESULT, servicePowerSetupOutput.getResult());
- }
-
- @Test
- public void testServicePowerSetupFailResult() {
- ServicePowerSetupInput servicePowerSetupInput = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput();
- Mockito.when(powerMgmtMock.setPower(servicePowerSetupInput)).thenReturn(Boolean.FALSE);
- OlmPowerService olmPowerServiceWithMock = new OlmPowerServiceImpl(dataBroker, powerMgmtMock,
- this.deviceTransactionManager, this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
- ServicePowerSetupOutput servicePowerSetupOutput =
- olmPowerServiceWithMock.servicePowerSetup(servicePowerSetupInput);
- Assert.assertEquals(ResponseCodes.FAILED_RESULT, servicePowerSetupOutput.getResult());
- }
}
import java.util.Map;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerResetInput;
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.NodeInfoBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.CurrentPmlist;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.CurrentPmlistBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.current.pm.MeasurementsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.current.pm.ResourceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.current.pm.measurements.MeasurementBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.currentpmlist.CurrentPm;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.currentpmlist.CurrentPmBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.currentpmlist.CurrentPmKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmDataType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmNamesEnum;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.pm.measurement.PmParameterNameBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev161014.resource.ResourceTypeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev161014.resource.resource.resource.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.PmGranularity;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.olm.get.pm.input.ResourceIdentifierBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.optical.renderer.nodes.Nodes;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.optical.renderer.nodes.NodesBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint32;
public final class OlmPowerServiceRpcImplUtil {
}
public static GetPmInput getGetPmInput() {
- GetPmInput input = new GetPmInputBuilder().setGranularity(PmGranularity._15min).setNodeId("node1")
- .setResourceIdentifier(new ResourceIdentifierBuilder().setCircuitPackName("circuit pack name")
- .setResourceName("resource name").build()).setResourceType(ResourceTypeEnum.Device).build();
+ GetPmInput input = new GetPmInputBuilder()
+ .setNodeId("node1")
+ .setGranularity(PmGranularity._15min)
+ .setResourceIdentifier(new ResourceIdentifierBuilder()
+ .setResourceName("ots-deg1").build())
+ .setResourceType(ResourceTypeEnum.Interface).build();
return input;
}
+ public static CurrentPmlist getCurrentPmList121() {
+ CurrentPm currentPm = new CurrentPmBuilder()
+ .setId("id")
+ .setGranularity(org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity._15min)
+ .setResource(new ResourceBuilder()
+ .setResourceType(new ResourceTypeBuilder()
+ .setType(ResourceTypeEnum.Interface)
+ .build())
+ .setResource(new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev161014.resource
+ .ResourceBuilder()
+ .setResource(new InterfaceBuilder()
+ .setInterfaceName("ots-deg1")
+ .build())
+ .build())
+ .build())
+ .setMeasurements(List.of(
+ new MeasurementsBuilder()
+ .setMeasurement(new MeasurementBuilder()
+ .setPmParameterName(new PmParameterNameBuilder()
+ .setType(PmNamesEnum.OpticalPowerInput)
+ .build())
+ .setPmParameterValue(new PmDataType(Decimal64.valueOf("3")))
+ .build())
+ .build()))
+ .build();
+ Map<CurrentPmKey, CurrentPm> currentPmMap = new HashMap<>();
+ currentPmMap.put(currentPm.key(), currentPm);
+ return new CurrentPmlistBuilder()
+ .setCurrentPm(currentPmMap)
+ .build();
+ }
+
public static ServicePowerSetupInput getServicePowerSetupInputForTransponder() {
return new ServicePowerSetupInputBuilder()
.setNodes(List.of(
.build();
}
- public static ServicePowerTurndownInput getServicePowerTurndownInput2() {
- Nodes node1 = new NodesBuilder().setDestTp("destdeg").setSrcTp("src").setNodeId("node 1").build();
- Nodes node2 = new NodesBuilder().setDestTp("destdeg").setSrcTp("src").setNodeId("node 2").build();
- List<Nodes> nodes = new ArrayList<>();
- nodes.add(node1);
- nodes.add(node2);
- ServicePowerTurndownInput input = new ServicePowerTurndownInputBuilder()
- .setNodes(nodes)
- .setServiceName("service 1")
- .setWaveNumber(Uint32.valueOf("1"))
- .setLowerSpectralSlotNumber(Uint32.valueOf(761))
- .setHigherSpectralSlotNumber(Uint32.valueOf(768)).build();
-
- return input;
- }
-
-
public static CalculateSpanlossBaseInput getCalculateSpanlossBaseInputLink() {
CalculateSpanlossBaseInput input = new CalculateSpanlossBaseInputBuilder()
.setLinkId(new LinkId("ROADM-A1-to-ROADM-C1"))
return input;
}
- public static CalculateSpanlossBaseInput getCalculateSpanlossBaseInput2() {
- CalculateSpanlossBaseInput input = new CalculateSpanlossBaseInputBuilder()
- .setLinkId(new LinkId("link 1"))
- .setSrcType(CalculateSpanlossBaseInput.SrcType.All).build();
- return input;
- }
-
- public static CalculateSpanlossCurrentInput getCalculateSpanlossCurrentInput() {
- CalculateSpanlossCurrentInput input = new CalculateSpanlossCurrentInputBuilder()
- .build();
- return input;
- }
-
public static ServicePowerResetInput getServicePowerResetInput() {
ServicePowerResetInput input = new ServicePowerResetInputBuilder()
.setServiceName("service 1").build();