use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadContainerMappingTest method testWithNullList.
// the List is not allowed to be null because of the way the constructor is
// defined
@Test
public void testWithNullList() {
final List<PeriodicMeterReadsResponseItemDto> meterReads = null;
final PeriodTypeDto periodType = PeriodTypeDto.DAILY;
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
new PeriodicMeterReadsResponseDto(periodType, meterReads);
});
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto 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.dto.valueobjects.smartmetering.PeriodTypeDto in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadsContainerGasMappingTest method testWithNullList.
// the List is not allowed to be null because of the way the constructor is
// defined
@Test
public void testWithNullList() {
final List<PeriodicMeterReadsGasResponseItemDto> meterReads = null;
final PeriodTypeDto periodType = PeriodTypeDto.DAILY;
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
new PeriodicMeterReadGasResponseDto(periodType, meterReads);
});
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadsContainerGasMappingTest method testWithEmptyList.
// Test if mapping with an empty List succeeds
@Test
public void testWithEmptyList() {
final List<PeriodicMeterReadsGasResponseItemDto> meterReads = new ArrayList<>();
final PeriodTypeDto periodType = PeriodTypeDto.DAILY;
final PeriodicMeterReadGasResponseDto periodicMeterReadsContainerGasDto = new PeriodicMeterReadGasResponseDto(periodType, meterReads);
final PeriodicMeterReadsContainerGas periodicMeterReadContainerGas = this.monitoringMapper.map(periodicMeterReadsContainerGasDto, PeriodicMeterReadsContainerGas.class);
assertThat(periodicMeterReadContainerGas).isNotNull();
assertThat(periodicMeterReadContainerGas.getPeriodicMeterReadsGas()).isEmpty();
assertThat(periodicMeterReadContainerGas.getPeriodType().name()).isEqualTo(periodicMeterReadsContainerGasDto.getPeriodType().name());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto in project open-smart-grid-platform by OSGP.
the class PeriodicMeterReadsContainerGasMappingTest method testWithNonEmptyList.
// Test if mapping with a non-empty List succeeds
@Test
public void testWithNonEmptyList() {
// build test data
final DlmsMeterValueDto consumption = 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 PeriodicMeterReadsGasResponseItemDto periodicMeterReadsGasDto = new PeriodicMeterReadsGasResponseItemDto(new Date(), consumption, new Date(), amrProfileStatusCodeDto);
final List<PeriodicMeterReadsGasResponseItemDto> meterReads = new ArrayList<>();
meterReads.add(periodicMeterReadsGasDto);
final PeriodTypeDto periodType = PeriodTypeDto.DAILY;
final PeriodicMeterReadGasResponseDto periodicMeterReadsContainerDto = new PeriodicMeterReadGasResponseDto(periodType, meterReads);
// actual mapping
final PeriodicMeterReadsContainerGas periodicMeterReadsContainerGas = this.monitoringMapper.map(periodicMeterReadsContainerDto, PeriodicMeterReadsContainerGas.class);
// test mapping
assertThat(periodicMeterReadsContainerGas).withFailMessage("Mapping must take place. So the result cannot be null.").isNotNull();
assertThat(periodicMeterReadsContainerGas.getPeriodType().name()).withFailMessage("After the mapping the name of the period must be the same.").isEqualTo(periodicMeterReadsContainerDto.getPeriodType().name());
assertThat(periodicMeterReadsContainerGas.getPeriodicMeterReadsGas().size()).withFailMessage("The number of periodic meter reads before and after the mapping must be equal.").isEqualTo(periodicMeterReadsContainerDto.getPeriodicMeterReadsGas().size());
assertThat(periodicMeterReadsContainerGas.getPeriodicMeterReadsGas().get(0).getLogTime()).withFailMessage("After the mapping the log time of the first entry must be the same.").isEqualTo(periodicMeterReadsContainerDto.getPeriodicMeterReadsGas().get(0).getLogTime());
assertThat(periodicMeterReadsContainerGas.getPeriodicMeterReadsGas().get(0).getCaptureTime()).withFailMessage("After the mapping the capture time of the first entry must be the same.").isEqualTo(periodicMeterReadsContainerDto.getPeriodicMeterReadsGas().get(0).getCaptureTime());
assertThat(periodicMeterReadsContainerGas.getPeriodicMeterReadsGas().get(0).getConsumption().getValue()).withFailMessage("After the mapping the consumption must be equal.").isEqualTo(new BigDecimal("1.0"));
assertThat(periodicMeterReadsContainerGas.getPeriodicMeterReadsGas().get(0).getConsumption().getOsgpUnit()).withFailMessage("After the mapping the osgp unit value must be the same.").isEqualTo(OsgpUnit.M3);
assertThat(periodicMeterReadsContainerGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlags().size()).withFailMessage("After the mapping the size of the arm profile status code flags must be the same.").isEqualTo(periodicMeterReadsContainerDto.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlags().size());
assertThat(periodicMeterReadsContainerGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlags().contains(AmrProfileStatusCodeFlag.CRITICAL_ERROR)).withFailMessage("After the mapping the amr profile status code flags must contain the CRITICAL_ERROR flag.").isTrue();
}
Aggregations