Search in sources :

Example 1 with MeasurementGroup

use of org.opensmartgridplatform.domain.da.measurements.MeasurementGroup in project open-smart-grid-platform by OSGP.

the class DomainDistributionAutomationMapperTest method testMeasurementGroupMapping.

@Test
public void testMeasurementGroupMapping() {
    // Arrange
    final String groupIdentification = "215";
    final float[] gasFlowMeasurements = { 401.70001f, 88.575f };
    final MeasurementGroup expected = DomainMeasurementsFactory.gasFlowMeasurementGroup(groupIdentification, gasFlowMeasurements);
    final MeasurementGroupDto dtoMeasurementGroup = DtoMeasurementsFactory.gasFlowMeasurementGroup(groupIdentification, gasFlowMeasurements);
    // Act
    final MeasurementGroup actual = this.mapper.map(dtoMeasurementGroup, MeasurementGroup.class);
    // Assert
    assertThat(actual).isEqualTo(expected);
}
Also used : MeasurementGroupDto(org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto) MeasurementGroup(org.opensmartgridplatform.domain.da.measurements.MeasurementGroup) Test(org.junit.jupiter.api.Test)

Example 2 with MeasurementGroup

use of org.opensmartgridplatform.domain.da.measurements.MeasurementGroup 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);
}
Also used : MeasurementReportDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto) ArrayList(java.util.ArrayList) MeasurementGroupDto(org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto) MeasurementReport(org.opensmartgridplatform.domain.da.measurements.MeasurementReport) MeasurementGroup(org.opensmartgridplatform.domain.da.measurements.MeasurementGroup) MeasurementReportHeaderDto(org.opensmartgridplatform.dto.da.measurements.MeasurementReportHeaderDto) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 MeasurementGroup (org.opensmartgridplatform.domain.da.measurements.MeasurementGroup)2 MeasurementGroupDto (org.opensmartgridplatform.dto.da.measurements.MeasurementGroupDto)2 ArrayList (java.util.ArrayList)1 MeasurementReport (org.opensmartgridplatform.domain.da.measurements.MeasurementReport)1 MeasurementReportDto (org.opensmartgridplatform.dto.da.measurements.MeasurementReportDto)1 MeasurementReportHeaderDto (org.opensmartgridplatform.dto.da.measurements.MeasurementReportHeaderDto)1