X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=olm%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Folm%2FOlmPowerServiceRpcImplTest.java;h=19ed220051652313d58371cb154aac760a8f6562;hb=b1b3bafd549bb501937cea5c976d5344608b6ed3;hp=92bc79e65e5ac03774e93ef1612324068634273d;hpb=213a09651d6a2a0a32fd92e743e3606473edabd9;p=transportpce.git diff --git a/olm/src/test/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImplTest.java b/olm/src/test/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImplTest.java index 92bc79e65..19ed22005 100644 --- a/olm/src/test/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImplTest.java +++ b/olm/src/test/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImplTest.java @@ -9,323 +9,136 @@ package org.opendaylight.transportpce.olm; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; import com.google.common.util.concurrent.ListenableFuture; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; import java.util.concurrent.ExecutionException; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -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.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.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossBaseImpl; +import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossCurrentImpl; +import org.opendaylight.transportpce.olm.rpc.impl.GetPmImpl; +import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerResetImpl; +import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerSetupImpl; +import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerTurndownImpl; import org.opendaylight.transportpce.olm.service.OlmPowerService; -import org.opendaylight.transportpce.olm.service.OlmPowerServiceImpl; -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.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.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.CalculateSpanlossCurrentInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentOutputBuilder; 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.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.ServicePowerResetOutputBuilder; 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.ServicePowerSetupOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupOutputBuilder; 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.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.LayerRateBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.current.pm.Measurements; -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.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.PmGranularity; -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.DeviceBuilder; -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.CircuitPackBuilder; 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.yangtools.yang.common.ErrorSeverity; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.common.Uint64; -public class OlmPowerServiceRpcImplTest extends AbstractTest { +@ExtendWith(MockitoExtension.class) +class OlmPowerServiceRpcImplTest extends AbstractTest { - private MountPoint mountPoint; - private MountPointService mountPointService; - private DeviceTransactionManager deviceTransactionManager; - private CrossConnect crossConnect; - private OpenRoadmInterfaces openRoadmInterfaces; - private PortMapping portMapping; - private PowerMgmt powerMgmt; + @Mock private OlmPowerService olmPowerService; - private OlmPowerServiceRpcImpl olmPowerServiceRpc; - 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; - - @BeforeEach - public void setUp() { - this.mountPoint = new MountPointStub(getDataBroker()); - this.mountPointService = new MountPointServiceStub(mountPoint); - this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000); - 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); - this.crossConnectImpl121 = new CrossConnectImpl121(deviceTransactionManager); - this.crossConnectImpl22 = new CrossConnectImpl221(deviceTransactionManager); - this.crossConnectImpl710 = new CrossConnectImpl710(deviceTransactionManager); - this.crossConnect = new CrossConnectImpl(deviceTransactionManager, this.mappingUtils, this.crossConnectImpl121, - this.crossConnectImpl22, this.crossConnectImpl710); - this.portMappingVersion710 = new PortMappingVersion710(getDataBroker(), deviceTransactionManager); - this.portMappingVersion22 = new PortMappingVersion221(getDataBroker(), deviceTransactionManager); - this.portMappingVersion121 = new PortMappingVersion121(getDataBroker(), deviceTransactionManager); - this.portMapping = new PortMappingImpl(getDataBroker(), this.portMappingVersion710, - this.portMappingVersion22, this.portMappingVersion121); - this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager); - 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.portMapping = Mockito.spy(this.portMapping); - this.powerMgmt = new PowerMgmtImpl(getDataBroker(), this.openRoadmInterfaces, this.crossConnect, - this.deviceTransactionManager, this.portMapping); - this.olmPowerService = new OlmPowerServiceImpl(getDataBroker(), this.powerMgmt, - this.deviceTransactionManager, this.portMapping,mappingUtils,openRoadmInterfaces); - this.olmPowerServiceRpc = new OlmPowerServiceRpcImpl(this.olmPowerService); - //TODO - this.olmPowerServiceRpc = Mockito.mock(OlmPowerServiceRpcImpl.class); - } - - @Test - public void pmIsNotPresentTest() throws ExecutionException, InterruptedException { - GetPmInput input = OlmPowerServiceRpcImplUtil.getGetPmInput(); - //TODO -// ListenableFuture> output = this.olmPowerServiceRpc.getPm(input); -// assertEquals(new GetPmOutputBuilder().build(), output.get().getResult()); -// assertEquals(null, output.get().getResult().getResourceId()); -// assertEquals(null, output.get().getResult().getMeasurements()); -// assertEquals(null, output.get().getResult().getGranularity()); -// assertEquals(null, output.get().getResult().getNodeId()); -// assertEquals(null, output.get().getResult().getResourceIdentifier()); -// assertEquals(null, output.get().getResult().getResourceType()); - } + @Mock + private RpcProviderService rpcProviderService; @Test - public void testGetPm1() throws ExecutionException, InterruptedException { - Measurements measurements = new MeasurementsBuilder().setMeasurement( - new MeasurementBuilder() - .setPmParameterUnit("unit") - .setPmParameterName(new PmParameterNameBuilder() - .setExtension("123") - .setType(PmNamesEnum.DefectSeconds).build()) - .setPmParameterValue(new PmDataType(Uint64.valueOf(1234))).build()) - .build(); - List measurementsList = new ArrayList(); - measurementsList.add(measurements); - - org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev161014.resource.Resource resource = - new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev161014.resource.ResourceBuilder() - .setResource(new CircuitPackBuilder().setCircuitPackName("circuit pack name").build()).build(); - - org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.current.pm.Resource resource2 = - new org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.current.pm.ResourceBuilder() - .setDevice(new DeviceBuilder().setNodeId("node 1").build()) - .setResourceType(new ResourceTypeBuilder() - .setExtension("123") - .setType(ResourceTypeEnum.Device).build()) - .setResource(resource).build(); - CurrentPm currentPm = new CurrentPmBuilder() + void testGetPmFailWithNodeIdNull() throws InterruptedException, ExecutionException { + GetPmInput input = new GetPmInputBuilder() .setGranularity(PmGranularity._15min) - .setId("id") - .setLayerRate(new LayerRateBuilder().build()) - .setMeasurements(measurementsList) - .setResource(resource2) - .setRetrievalTime(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715 - .DateAndTime("2018-11-01T12:00:31.456449+06:00")).build(); - - Map currentPmList = new HashMap<>(); - currentPmList.put(currentPm.key(),currentPm); - - Optional currentPmlistOptional = Optional.of(new CurrentPmlistBuilder() - .setCurrentPm(currentPmList).build()); - - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.get.pm.output.Measurements - measurements1 = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.get.pm - .output.MeasurementsBuilder().setPmparameterName("name").setPmparameterValue("1234").build(); - - - List measurementsList1 = new ArrayList<>(); - measurementsList1.add(measurements1); - - GetPmInput input = OlmPowerServiceRpcImplUtil.getGetPmInput(); - GetPmOutputBuilder pmOutputBuilder = new GetPmOutputBuilder().setNodeId(input.getNodeId()) - .setResourceType(input.getResourceType()) - .setResourceIdentifier(input.getResourceIdentifier()) - .setGranularity(input.getGranularity()) - .setMeasurements(measurementsList1); - - - ListenableFuture> output = this.olmPowerServiceRpc.getPm(input); - //TODO -// assertEquals(new GetPmOutputBuilder().build(), output.get().getResult()); -// assertEquals(null, output.get().getResult().getResourceId()); + .setResourceIdentifier(new ResourceIdentifierBuilder() + .setResourceName("ots-deg1").build()) + .setResourceType(ResourceTypeEnum.Interface) + .build(); + ListenableFuture> output = new GetPmImpl(olmPowerService).invoke(input); + assertFalse(output.get().isSuccessful()); + assertNull(output.get().getResult()); + assertEquals(ErrorType.RPC, output.get().getErrors().get(0).getErrorType()); + assertEquals("Error with input parameters", output.get().getErrors().get(0).getMessage()); + assertEquals(ErrorSeverity.ERROR, output.get().getErrors().get(0).getSeverity()); + assertEquals(ErrorTag.OPERATION_FAILED, output.get().getErrors().get(0).getTag()); } -// @Test -// public void testGetPm2() throws ExecutionException, InterruptedException { -// this.olmPowerService = Mockito.spy(this.olmPowerService); -// GetPmInput input = new GetPmInputBuilder().setGranularity(PmGranularity._15min).setNodeId("node1") -// .setResourceIdentifier(new ResourceIdentifierBuilder().setCircuitPackName("circuit pack name") -// .setResourceName("resource name").build()).setResourceType(ResourceTypeEnum.Device).build(); -// org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.get.pm.output.Measurements -// measurements1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.get.pm -// .output.MeasurementsBuilder().setPmparameterName("name").setPmparameterValue("1234").build(); -// -// -// List measurementsList1 = new ArrayList<>(); -// measurementsList1.add(measurements1); -// -// GetPmOutputBuilder pmOutputBuilder = new GetPmOutputBuilder().setNodeId(input.getNodeId()) -// .setResourceType(input.getResourceType()) -// .setResourceIdentifier(input.getResourceIdentifier()) -// .setGranularity(input.getGranularity()) -// .setMeasurements(measurementsList1); -// -// Mockito.doReturn(pmOutputBuilder.build()).when(this.olmPowerService).getPm(Mockito.any()); -// ListenableFuture> output = this.olmPowerServiceRpc.getPm(input); -// assertEquals(pmOutputBuilder.build(), output.get().getResult()); -// assertEquals(true, output.get().isSuccessful()); -// } - @Test - public void testGetPm3() throws ExecutionException, InterruptedException { - GetPmInput input = OlmPowerServiceRpcImplUtil.getGetPmInput(); - ListenableFuture> output = this.olmPowerServiceRpc.getPm(input); - //TODO -// assertEquals(new GetPmOutputBuilder().build(), output.get().getResult()); -// assertEquals(null, output.get().getResult().getResourceId()); -// assertEquals(null, output.get().getResult().getMeasurements()); -// assertEquals(null, output.get().getResult().getGranularity()); -// assertEquals(null, output.get().getResult().getNodeId()); -// assertEquals(null, output.get().getResult().getResourceIdentifier()); -// assertEquals(null, output.get().getResult().getResourceType()); + void testGetPmWithSuccess() throws InterruptedException, ExecutionException { + GetPmInput input = new GetPmInputBuilder() + .setNodeId("nodeId") + .build(); + when(this.olmPowerService.getPm(any())).thenReturn(new GetPmOutputBuilder().build()); + ListenableFuture> output = new GetPmImpl(olmPowerService).invoke(input); + assertTrue(output.get().isSuccessful()); + assertEquals(new GetPmOutputBuilder().build(), output.get().getResult()); } @Test - public void testServicePowerSetup1() throws ExecutionException, InterruptedException { + void testServicePowerSetup() throws InterruptedException, ExecutionException { ServicePowerSetupInput input = OlmPowerServiceRpcImplUtil.getServicePowerSetupInput(); - //TODO - Mockito.when(this.olmPowerServiceRpc.servicePowerSetup(Mockito.any())) - .thenReturn(RpcResultBuilder.success(new ServicePowerSetupOutputBuilder() - .setResult("Success").build()).buildFuture()); - ListenableFuture> output = this.olmPowerServiceRpc.servicePowerSetup(input); - assertEquals(new ServicePowerSetupOutputBuilder().setResult("Success").build(), output.get() - .getResult()); - assertEquals("Success", output.get().getResult().getResult()); - assertEquals(true, output.get().isSuccessful()); + when(this.olmPowerService.servicePowerSetup(any())).thenReturn(new ServicePowerSetupOutputBuilder().build()); + ListenableFuture> output = + new ServicePowerSetupImpl(olmPowerService).invoke(input); + assertTrue(output.get().isSuccessful()); + assertEquals(new ServicePowerSetupOutputBuilder().build(), output.get().getResult()); } - @Test - public void testServicePowerTurndown1() throws ExecutionException, InterruptedException { + void testServicePowerTurndown() throws InterruptedException, ExecutionException { ServicePowerTurndownInput input = OlmPowerServiceRpcImplUtil.getServicePowerTurndownInput(); - //TODO - Mockito.when(this.olmPowerServiceRpc.servicePowerTurndown(Mockito.any())) - .thenReturn(RpcResultBuilder.success(new ServicePowerTurndownOutputBuilder() - .setResult("Success").build()).buildFuture()); - ListenableFuture> output = this.olmPowerServiceRpc - .servicePowerTurndown(input); - assertEquals(new ServicePowerTurndownOutputBuilder().setResult("Success").build(), output.get() - .getResult()); - assertEquals("Success", output.get().getResult().getResult()); - assertEquals(true, output.get().isSuccessful()); + when(this.olmPowerService.servicePowerTurndown(any())) + .thenReturn(new ServicePowerTurndownOutputBuilder().build()); + var output = new ServicePowerTurndownImpl(olmPowerService).invoke(input); + assertTrue(output.get().isSuccessful()); + assertEquals(new ServicePowerTurndownOutputBuilder().build(), output.get().getResult()); } - /* @Test - public void testCalculateSpanlossBase1() throws ExecutionException, InterruptedException { - CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInput(); - //TODO - Mockito.when(this.olmPowerServiceRpc.calculateSpanlossBase(Mockito.any())) - .thenReturn(RpcResultBuilder.success(new CalculateSpanlossBaseOutputBuilder() - .setResult("Failed").build()).buildFuture()); - ListenableFuture> output = this.olmPowerServiceRpc - .calculateSpanlossBase(input); - assertEquals(new CalculateSpanlossBaseOutputBuilder().setResult("Failed").build(), - output.get().getResult()); - assertEquals("Failed", output.get().getResult().getResult()); - assertEquals(true, output.get().isSuccessful()); - }*/ + void testCalculateSpanlossBase() throws InterruptedException, ExecutionException { + CalculateSpanlossBaseInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossBaseInputAll(); + when(this.olmPowerService.calculateSpanlossBase(any())) + .thenReturn(new CalculateSpanlossBaseOutputBuilder().build()); + var output = new CalculateSpanlossBaseImpl(olmPowerService).invoke(input); + assertTrue(output.get().isSuccessful()); + assertEquals(new CalculateSpanlossBaseOutputBuilder().build(), output.get().getResult()); + } - //TODO -/** @Test - public void testCalculateSpanlossCurrent1() throws ExecutionException, InterruptedException { - CalculateSpanlossCurrentInput input = OlmPowerServiceRpcImplUtil.getCalculateSpanlossCurrentInput(); - //TODO - Mockito.when(this.olmPowerServiceRpc.calculateSpanlossCurrent(Mockito.any())) - .thenReturn(RpcResultBuilder.success(new CalculateSpanlossCurrentOutputBuilder() - .setResult("success").build()).buildFuture()); - ListenableFuture> output = this.olmPowerServiceRpc - .calculateSpanlossCurrent(input); - assertEquals(null, output.get().getResult()); - assertEquals(true, output.get().isSuccessful()); + @Test + void testCalculateSpanlossCurrent() throws InterruptedException, ExecutionException { + CalculateSpanlossCurrentInput input = new CalculateSpanlossCurrentInputBuilder().build(); + when(this.olmPowerService.calculateSpanlossCurrent(any())) + .thenReturn(new CalculateSpanlossCurrentOutputBuilder().build()); + var output = new CalculateSpanlossCurrentImpl(olmPowerService).invoke(input); + assertTrue(output.get().isSuccessful()); + assertEquals(new CalculateSpanlossCurrentOutputBuilder().build(), output.get().getResult()); } @Test - public void testServicePowerResetInput() throws ExecutionException, InterruptedException { + void testServicePowerReset() throws InterruptedException, ExecutionException { ServicePowerResetInput input = OlmPowerServiceRpcImplUtil.getServicePowerResetInput(); - //TODO - Mockito.when(this.olmPowerServiceRpc.calculateSpanlossCurrent(Mockito.any())) - .thenReturn(RpcResultBuilder.success(new CalculateSpanlossCurrentOutputBuilder() - .setResult(null).build()).buildFuture()); - ListenableFuture> output = this.olmPowerServiceRpc - .servicePowerReset(input); - assertEquals(null, output.get().getResult()); - assertEquals(true, output.get().isSuccessful()); + when(this.olmPowerService.servicePowerReset(any())) + .thenReturn(new ServicePowerResetOutputBuilder().build()); + var output = new ServicePowerResetImpl(olmPowerService).invoke(input); + assertTrue(output.get().isSuccessful()); + assertEquals(new ServicePowerResetOutputBuilder().build(), output.get().getResult()); } -**/ }