use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityResponse in project open-smart-grid-platform by OSGP.
the class ActualPowerQualityDtoConverter method convert.
@Override
public ActualPowerQualityResponse convert(final ActualPowerQualityResponseDto source, final Type<? extends ActualPowerQualityResponse> destinationType, final MappingContext mappingContext) {
if (source.getActualPowerQualityData() != null) {
final ActualPowerQualityDataDto responseDataDto = source.getActualPowerQualityData();
final List<PowerQualityObject> powerQualityObjects = new ArrayList<>(this.mapperFacade.mapAsList(responseDataDto.getPowerQualityObjects(), PowerQualityObject.class));
final List<PowerQualityValue> powerQualityValues = this.makePowerQualityValues(responseDataDto);
final ActualPowerQualityData actualPowerQualityData = new ActualPowerQualityData(powerQualityObjects, powerQualityValues);
return new ActualPowerQualityResponse(actualPowerQualityData);
} else {
return new ActualPowerQualityResponse(null);
}
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityResponse in project open-smart-grid-platform by OSGP.
the class MonitoringService method handleActualPowerQualityResponse.
public void handleActualPowerQualityResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final ActualPowerQualityResponseDto actualPowerQualityResponseDto) {
LOGGER.info("handleGetActualPowerQualityResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_LOG_MSG, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ActualPowerQualityResponse actualPowerQualityResponse = this.monitoringMapper.map(actualPowerQualityResponseDto, ActualPowerQualityResponse.class);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(actualPowerQualityResponse).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityResponse in project open-smart-grid-platform by OSGP.
the class ActualPowerQualityResponseMappingTest method shouldConvertActualPowerQualityResponse.
@Test
public void shouldConvertActualPowerQualityResponse() {
// Arrange
final List<PowerQualityObject> powerQualityObjects = this.makePowerQualityObjects();
final List<PowerQualityValue> powerQualityValues = this.makePowerQualityValues();
final ActualPowerQualityData responseData = new ActualPowerQualityData(powerQualityObjects, powerQualityValues);
final ActualPowerQualityResponse source = new ActualPowerQualityResponse(responseData);
// Act
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.ActualPowerQualityResponse target = this.monitoringMapper.map(source, org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.ActualPowerQualityResponse.class);
// Assert
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityData mappedResponseData = target.getActualPowerQualityData();
this.assertPowerQualityObjects(mappedResponseData.getPowerQualityObjects().getPowerQualityObject(), powerQualityObjects);
this.assertPowerQualityValues(mappedResponseData.getPowerQualityValues().getPowerQualityValue(), powerQualityValues);
}
Aggregations