use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class MeasurementReportFactory method getMeasurementReportDto.
public static MeasurementReportDto getMeasurementReportDto() {
final MeasurementReportHeaderDto mrh = new MeasurementReportHeaderDto("M_SP_NA_1", "INTERROGATED_BY_STATION", 0, 0);
final MeasurementGroupDto mg1 = getMeasurementGroup(Iec60870DeviceFactory.LMD_1_IOA, LMD_1_ON);
final MeasurementGroupDto mg2 = getMeasurementGroup(Iec60870DeviceFactory.LMD_2_IOA, LMD_2_ON);
return new MeasurementReportDto(mrh, Arrays.asList(mg1, mg2));
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class LightMeasurementGatewayDeviceResponseServiceTest method processShouldDelegateProcessingReportsForEachDeviceBehindTheGateway.
@Test
void processShouldDelegateProcessingReportsForEachDeviceBehindTheGateway() {
// Arrange
final Iec60870Device gatewayDevice = Iec60870DeviceFactory.getGatewayDevice();
final Iec60870Device lightMeasurementDevice1 = Iec60870DeviceFactory.getLightMeasurementDevice1();
final Iec60870Device lightMeasurementDevice2 = Iec60870DeviceFactory.getLightMeasurementDevice2();
when(this.iec60870DeviceRepository.findByGatewayDeviceIdentification(gatewayDevice.getDeviceIdentification())).thenReturn(Arrays.asList(lightMeasurementDevice1, lightMeasurementDevice2));
final MeasurementReportDto measurementReportDto = MeasurementReportFactory.getMeasurementReportDto();
final ResponseMetadata responseMetadata = new ResponseMetadata.Builder().withCorrelationUid(CORRELATION_UID).withDeviceIdentification(Iec60870DeviceFactory.GATEWAY_DEVICE_IDENTIFICATION).withOrganisationIdentification(ORGANISATION_IDENTIFICATION).build();
// Act
this.lightMeasurementGatewayDeviceResponseService.process(measurementReportDto, responseMetadata);
// Assert
verify(this.lightMeasurementDeviceResponseService, times(1)).sendLightSensorStatusResponse(same(measurementReportDto), same(lightMeasurementDevice1), same(responseMetadata), anyString());
verify(this.lightMeasurementDeviceResponseService, times(1)).sendLightSensorStatusResponse(same(measurementReportDto), same(lightMeasurementDevice2), same(responseMetadata), anyString());
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class SinglePointWithQualityAsduHandlerTest method createMeasurementReportDto.
private MeasurementReportDto createMeasurementReportDto() {
final MeasurementReportHeaderDto mrh = new MeasurementReportHeaderDto(MEASUREMENT_TYPE, MEASUREMENT_REASON, MEASUREMENT_ORIGINATOR_ADDRESS, MEASUREMENT_COMMON_ADDRESS);
final MeasurementGroupDto mg1 = this.createMeasurementGroup(Integer.toString(LMD_1_IOA), LMD_1_ON);
final MeasurementGroupDto mg2 = this.createMeasurementGroup(Integer.toString(LMD_2_IOA), LMD_2_ON);
return new MeasurementReportDto(mrh, Arrays.asList(mg1, mg2));
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class MeasurementAsduHandlerTest method shouldSendMeasurementReportWhenHandlingAsdu.
@Test
void shouldSendMeasurementReportWhenHandlingAsdu() throws Exception {
// Arrange
final ASdu asdu = AsduFactory.ofType(ASduType.M_ME_TF_1);
final MeasurementReportDto measurementReportDto = this.mapper.map(asdu, MeasurementReportDto.class);
final ResponseMetadata responseMetadata = new ResponseMetadata.Builder().withCorrelationUid(CORRELATION_UID).withDeviceIdentification(DEVICE_IDENTIFICATION).withDeviceType(DEVICE_TYPE).withOrganisationIdentification(ORGANISATION_IDENTIFICATION).build();
when(this.converter.convert(asdu)).thenReturn(measurementReportDto);
when(this.deviceResponseServiceRegistry.forDeviceType(DEVICE_TYPE)).thenReturn(this.deviceResponseService);
// Act
this.asduHandler.handleAsdu(asdu, responseMetadata);
// Assert
verify(this.deviceResponseService).process(measurementReportDto, responseMetadata);
}
use of org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto in project open-smart-grid-platform by OSGP.
the class Iec60870AsduConverterTest method shouldConvertAsduToMeasurementReportDto.
@Test
public void shouldConvertAsduToMeasurementReportDto() {
// Arrange
final MeasurementReportDto expected = MEASUREMENT_REPORT_DTO;
final ASdu source = ASDU;
// Act
final MeasurementReportDto actual = this.mapper.map(source, MeasurementReportDto.class);
// Assert
assertThat(actual).isEqualTo(expected);
}
Aggregations