use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto 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.ActualPowerQualityResponseDto in project open-smart-grid-platform by OSGP.
the class GetActualPowerQualityCommandExecutor method makeActualPowerQualityResponseDto.
private ActualPowerQualityResponseDto makeActualPowerQualityResponseDto(final List<GetResult> resultList, final List<PowerQualityObjectMetadata> metadatas) throws ProtocolAdapterException {
final ActualPowerQualityResponseDto responseDto = new ActualPowerQualityResponseDto();
final ActualPowerQualityDataDto actualPowerQualityDataDto = this.makeActualPowerQualityDataDto(resultList, metadatas);
responseDto.setActualPowerQualityDataDto(actualPowerQualityDataDto);
return responseDto;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto in project open-smart-grid-platform by OSGP.
the class ActualPowerQualityResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
if (this.hasRegularResponseObject(responseMessage)) {
final ActualPowerQualityResponseDto actualPowerQualityResponseDto = (ActualPowerQualityResponseDto) responseMessage.getDataObject();
this.monitoringService.handleActualPowerQualityResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, actualPowerQualityResponseDto);
} else {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new OsgpException(ComponentType.DOMAIN_SMART_METERING, "DataObject for response message should be of type ActualPowerQualityResponseDto"));
}
}
Aggregations