Search in sources :

Example 1 with MeasurementReportDto

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));
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) MeasurementGroupDto(org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto) MeasurementReportHeaderDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportHeaderDto)

Example 2 with MeasurementReportDto

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());
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device) ResponseMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata) Test(org.junit.jupiter.api.Test)

Example 3 with MeasurementReportDto

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));
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) MeasurementGroupDto(org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto) MeasurementReportHeaderDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportHeaderDto)

Example 4 with MeasurementReportDto

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);
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) ASdu(org.openmuc.j60870.ASdu) ResponseMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata) Test(org.junit.jupiter.api.Test)

Example 5 with MeasurementReportDto

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);
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) ASdu(org.openmuc.j60870.ASdu) Test(org.junit.jupiter.api.Test)

Aggregations

MeasurementReportDto (org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto)11 Test (org.junit.jupiter.api.Test)6 ResponseMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata)4 ASdu (org.openmuc.j60870.ASdu)3 MeasurementGroupDto (org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto)3 MeasurementReportHeaderDto (org.opensmartgridplatform.dto.da.measurements.MeasurementReportHeaderDto)3 Iec60870Device (org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device)2 ArrayList (java.util.ArrayList)1 JMSException (javax.jms.JMSException)1 DeviceResponseService (org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.DeviceResponseService)1 MeasurementGroup (org.opensmartgridplatform.domain.da.measurements.MeasurementGroup)1 MeasurementReport (org.opensmartgridplatform.domain.da.measurements.MeasurementReport)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)1