use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadsContainerMappingTest method testWithEmptyList.
/**
* Tests the mapping of a PeriodMeterReadsContainer object with an empty List.
*/
@Test
public void testWithEmptyList() {
// build test data
final List<PeriodicMeterReads> periodicMeterReadsList = new ArrayList<>();
final PeriodicMeterReadsContainer periodicMeterReadsContainer = new PeriodicMeterReadsContainer(PERIODTYPE, periodicMeterReadsList);
// actual mapping
final PeriodicMeterReadsResponse periodicMeterReadsResponse = this.monitoringMapper.map(periodicMeterReadsContainer, PeriodicMeterReadsResponse.class);
// check mapping
assertThat(periodicMeterReadsResponse).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().isEmpty()).isTrue();
assertThat(periodicMeterReadsResponse.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadContainerMappingTest method testWithNonEmptyList.
// Test if mapping with a non-empty List succeeds
@Test
public void testWithNonEmptyList() {
// build test data
final DlmsMeterValueDto activeEnergyImport = new DlmsMeterValueDto(new BigDecimal(1.0), DlmsUnitTypeDto.M3);
final DlmsMeterValueDto activeEnergyExport = new DlmsMeterValueDto(new BigDecimal(1.0), DlmsUnitTypeDto.M3);
final Set<AmrProfileStatusCodeFlagDto> amrProfileStatusCodeFlagSet = new TreeSet<>();
amrProfileStatusCodeFlagSet.add(AmrProfileStatusCodeFlagDto.CRITICAL_ERROR);
final AmrProfileStatusCodeDto amrProfileStatusCodeDto = new AmrProfileStatusCodeDto(amrProfileStatusCodeFlagSet);
final PeriodicMeterReadsResponseItemDto periodicMeterReadsDto = new PeriodicMeterReadsResponseItemDto(new Date(), activeEnergyImport, activeEnergyExport, amrProfileStatusCodeDto);
final List<PeriodicMeterReadsResponseItemDto> meterReads = new ArrayList<>();
meterReads.add(periodicMeterReadsDto);
final PeriodTypeDto periodType = PeriodTypeDto.DAILY;
final PeriodicMeterReadsResponseDto periodicMeterReadsContainerDto = new PeriodicMeterReadsResponseDto(periodType, meterReads);
// actual mapping
final PeriodicMeterReadsContainer periodicMeterReadsContainer = this.monitoringMapper.map(periodicMeterReadsContainerDto, PeriodicMeterReadsContainer.class);
// test mapping
assertThat(periodicMeterReadsContainer).isNotNull();
assertThat(periodicMeterReadsContainer.getPeriodType().name()).isEqualTo(periodicMeterReadsContainerDto.getPeriodType().name());
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().size()).isEqualTo(periodicMeterReadsContainerDto.getPeriodicMeterReads().size());
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().get(0).getLogTime()).isEqualTo(periodicMeterReadsContainerDto.getPeriodicMeterReads().get(0).getLogTime());
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().get(0).getActiveEnergyImport().getValue()).isEqualTo(new BigDecimal("1.0"));
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().get(0).getActiveEnergyImport().getOsgpUnit()).isEqualTo(OsgpUnit.M3);
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().get(0).getActiveEnergyExport().getValue()).isEqualTo(new BigDecimal("1.0"));
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().get(0).getActiveEnergyExport().getOsgpUnit()).isEqualTo(OsgpUnit.M3);
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlags().size()).isEqualTo(periodicMeterReadsContainerDto.getPeriodicMeterReads().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlags().size());
assertThat(periodicMeterReadsContainer.getPeriodicMeterReads().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlags().contains(AmrProfileStatusCodeFlag.CRITICAL_ERROR)).isTrue();
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadsContainerMappingTest method testMappingWithFilledListAndSet.
/**
* Tests the mapping of a PeriodicMeterReadsContainer object with a filled List and Set.
*/
@Test
public void testMappingWithFilledListAndSet() {
// build test data
final OsgpMeterValue osgpMeterValue = new OsgpMeterValue(VALUE, OSGP_UNIT);
final Set<AmrProfileStatusCodeFlag> flagSet = new TreeSet<>();
flagSet.add(AMRCODEFLAG);
final AmrProfileStatusCode amrProfileStatusCode = new AmrProfileStatusCode(flagSet);
final PeriodicMeterReads periodicMeterReads = new PeriodicMeterReads(DATE, osgpMeterValue, osgpMeterValue, amrProfileStatusCode);
final List<PeriodicMeterReads> periodicMeterReadsList = new ArrayList<>();
periodicMeterReadsList.add(periodicMeterReads);
final PeriodicMeterReadsContainer periodicMeterReadsContainer = new PeriodicMeterReadsContainer(PERIODTYPE, periodicMeterReadsList);
// actual mapping
final PeriodicMeterReadsResponse periodicMeterReadsResponse = this.monitoringMapper.map(periodicMeterReadsContainer, PeriodicMeterReadsResponse.class);
// check mapping
assertThat(periodicMeterReadsResponse).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads()).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodType()).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0)).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyExport()).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyImport()).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getAmrProfileStatusCode()).isNotNull();
assertThat(periodicMeterReadsResponse.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().size()).isEqualTo(periodicMeterReadsList.size());
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyImport().getValue()).isEqualTo(VALUE);
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyImport().getUnit().name()).isEqualTo(OSGP_UNITTYPE.name());
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyExport().getValue()).isEqualTo(VALUE);
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getActiveEnergyExport().getUnit().name()).isEqualTo(OSGP_UNITTYPE.name());
assertThat(periodicMeterReadsResponse.getPeriodicMeterReads().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlag().get(0).name()).isEqualTo(AMRCODEFLAG.name());
// For more information on the mapping of Date to XmlGregorianCalendar
// objects, refer to the DateMappingTest
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadContainerMappingTest method testWithEmptyList.
// Test if mapping with an empty List succeeds
@Test
public void testWithEmptyList() {
final List<PeriodicMeterReadsResponseItemDto> meterReads = new ArrayList<>();
final PeriodTypeDto periodType = PeriodTypeDto.DAILY;
final PeriodicMeterReadsResponseDto periodicMeterReadsContainerDto = new PeriodicMeterReadsResponseDto(periodType, meterReads);
final PeriodicMeterReadsContainer periodicMeterReadContainer = this.monitoringMapper.map(periodicMeterReadsContainerDto, PeriodicMeterReadsContainer.class);
assertThat(periodicMeterReadContainer).isNotNull();
assertThat(periodicMeterReadContainer.getPeriodicMeterReads()).isEmpty();
assertThat(periodicMeterReadContainer.getPeriodType().name()).isEqualTo(periodicMeterReadsContainerDto.getPeriodType().name());
}
Aggregations