use of org.opensmartgridplatform.domain.da.measurements.MeasurementReport in project open-smart-grid-platform by OSGP.
the class DomainDistributionAutomationMapperTest method testMeasurementReportMapping.
@Test
public void testMeasurementReportMapping() {
// Arrange
final int commonAddress = 55;
final String groupIdentification = "137";
final float[] gasFlowMeasurements = { 78.733f, 21.000f };
// Arrange domain
final MeasurementGroup expectedGroup = DomainMeasurementsFactory.gasFlowMeasurementGroup(groupIdentification, gasFlowMeasurements);
final List<MeasurementGroup> expectedGroups = new ArrayList<>();
expectedGroups.add(expectedGroup);
final MeasurementReport expected = new MeasurementReport(DomainMeasurementsFactory.spontaneousReportHeader(commonAddress), expectedGroups);
// Arrange DTO
final MeasurementReportHeaderDto dtoHeader = DtoMeasurementsFactory.spontaneousReportHeader(commonAddress);
final MeasurementGroupDto dtoGroup = DtoMeasurementsFactory.gasFlowMeasurementGroup(groupIdentification, gasFlowMeasurements);
final List<MeasurementGroupDto> dtoGroups = new ArrayList<>();
dtoGroups.add(dtoGroup);
final MeasurementReportDto dtoReport = new MeasurementReportDto(dtoHeader, dtoGroups);
// Act
final MeasurementReport actual = this.mapper.map(dtoReport, MeasurementReport.class);
// Assert
assertThat(actual).isEqualTo(expected);
}
use of org.opensmartgridplatform.domain.da.measurements.MeasurementReport in project open-smart-grid-platform by OSGP.
the class MonitoringService method handleGetMeasurementReportResponse.
public void handleGetMeasurementReportResponse(final MeasurementReportDto measurementReportDto, final CorrelationIds ids, final String messageType, final ResponseMessageResultType responseMessageResultType, final OsgpException osgpException) {
LOGGER.info("handleResponse for MessageType: {}", messageType);
ResponseMessageResultType result = ResponseMessageResultType.OK;
MeasurementReport measurementReport = null;
OsgpException exception = osgpException;
try {
if (responseMessageResultType == ResponseMessageResultType.NOT_OK || osgpException != null) {
LOGGER.error("Device Response not ok.", osgpException);
throw osgpException;
}
this.rtuResponseService.handleResponseMessageReceived(LOGGER, ids.getDeviceIdentification(), true);
measurementReport = this.mapper.map(measurementReportDto, MeasurementReport.class);
} catch (final Exception e) {
LOGGER.error("Unexpected Exception", e);
result = ResponseMessageResultType.NOT_OK;
exception = this.ensureOsgpException(e, "Exception occurred while receiving Measurement Report");
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(ids).withResult(result).withOsgpException(exception).withDataObject(measurementReport).build();
this.responseMessageRouter.send(responseMessage, messageType);
}
Aggregations