use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto in project open-smart-grid-platform by OSGP.
the class GetActualPowerQualityCommandExecutorTest method testOtherReasonResult.
@Test
void testOtherReasonResult() throws ProtocolAdapterException {
this.actualPowerQualityRequestDto = new ActualPowerQualityRequestDto("PRIVATE");
final List<GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata> metadatas = GetActualPowerQualityCommandExecutor.getMetadatasPrivate();
doReturn(this.generateMockedResult(metadatas, AccessResultCode.OTHER_REASON)).when(this.dlmsHelper).getAndCheck(eq(this.conn), eq(this.dlmsDevice), eq("retrieve actual power quality"), any(AttributeAddress.class));
assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> {
new GetActualPowerQualityCommandExecutor(this.dlmsHelper).execute(this.conn, this.dlmsDevice, this.actualPowerQualityRequestDto, this.messageMetadata);
});
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto in project open-smart-grid-platform by OSGP.
the class GetActualPowerQualityCommandExecutorTest method executeAndAssert.
void executeAndAssert(final String profileType, final List<GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata> metadatas) throws ProtocolAdapterException {
this.actualPowerQualityRequestDto = new ActualPowerQualityRequestDto(profileType);
doReturn(this.generateMockedResult(metadatas, AccessResultCode.SUCCESS)).when(this.dlmsHelper).getAndCheck(eq(this.conn), eq(this.dlmsDevice), eq("retrieve actual power quality"), any(AttributeAddress.class));
final GetActualPowerQualityCommandExecutor executor = new GetActualPowerQualityCommandExecutor(this.dlmsHelper);
final ActualPowerQualityResponseDto responseDto = executor.execute(this.conn, this.dlmsDevice, this.actualPowerQualityRequestDto, this.messageMetadata);
assertThat(responseDto.getActualPowerQualityData().getPowerQualityValues()).hasSize(metadatas.size());
assertThat(responseDto.getActualPowerQualityData().getPowerQualityObjects()).hasSize(metadatas.size());
for (int i = 0; i < metadatas.size(); i++) {
final GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata metadata = metadatas.get(i);
final Serializable expectedValue = this.getExpectedValue(i, metadata);
final String expectedUnit = this.getExpectedUnit(metadata);
final PowerQualityObjectDto powerQualityObjectDto = responseDto.getActualPowerQualityData().getPowerQualityObjects().get(i);
assertThat(powerQualityObjectDto.getName()).isEqualTo(metadata.name());
assertThat(powerQualityObjectDto.getUnit()).isEqualTo(expectedUnit);
final PowerQualityValueDto powerQualityValue = responseDto.getActualPowerQualityData().getPowerQualityValues().get(i);
assertThat(powerQualityValue.getValue()).isEqualTo(expectedValue);
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto in project open-smart-grid-platform by OSGP.
the class GetActualPowerQualityRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(ActualPowerQualityRequestDto.class, requestObject);
final ActualPowerQualityRequestDto actualPowerQualityRequestDto = (ActualPowerQualityRequestDto) requestObject;
return this.monitoringService.requestActualPowerQuality(conn, device, actualPowerQualityRequestDto, messageMetadata);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto in project open-smart-grid-platform by OSGP.
the class MonitoringService method requestActualPowerQuality.
public void requestActualPowerQuality(final MessageMetadata messageMetadata, final ActualPowerQualityRequest request) throws FunctionalException {
LOGGER.info("requestActualPowerQuality for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
final ActualPowerQualityRequestDto requestDto = this.monitoringMapper.map(request, ActualPowerQualityRequestDto.class);
this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Aggregations