use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas in project open-smart-grid-platform by OSGP.
the class MeterReadsGasMappingTest method testMeterReadsGasMappingTest.
// Test the mapping of a complete MeterReadsGasDto object
@Test
public void testMeterReadsGasMappingTest() {
// build test data
final DlmsMeterValueDto consumption = new DlmsMeterValueDto(new BigDecimal(1.0), DlmsUnitTypeDto.M3);
final MeterReadsGasResponseDto meterReadsGasDto = new MeterReadsGasResponseDto(new Date(), consumption, new Date());
// actual mapping
final MeterReadsGas meterReadsGas = this.monitoringMapper.map(meterReadsGasDto, MeterReadsGas.class);
// test mapping
assertThat(meterReadsGas).isNotNull();
assertThat(meterReadsGas.getLogTime()).isEqualTo(meterReadsGasDto.getLogTime());
assertThat(meterReadsGas.getCaptureTime()).isEqualTo(meterReadsGasDto.getCaptureTime());
final BigDecimal bigDecimal1 = consumption.getValue();
final BigDecimal bigDecimal2 = meterReadsGas.getConsumption().getValue();
assertThat(bigDecimal1.compareTo(bigDecimal2) == 0).isTrue();
assertThat(meterReadsGas.getConsumption().getOsgpUnit()).isEqualTo(OsgpUnit.M3);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas in project open-smart-grid-platform by OSGP.
the class MeterReadsGasMappingTest method testMeterReadsGasMapping.
/**
* Tests if a MeterReadsGas object can be mapped
*/
@Test
public void testMeterReadsGasMapping() {
// build test data
final OsgpMeterValue osgpMeterValue = new OsgpMeterValue(VALUE, OSGP_UNIT);
final MeterReadsGas meterReadsGas = new MeterReadsGas(DATE, osgpMeterValue, DATE);
// actual mapping
final ActualMeterReadsGasResponse actualMeterReadsGasResponse = this.monitoringMapper.map(meterReadsGas, ActualMeterReadsGasResponse.class);
// check mapping
assertThat(actualMeterReadsGasResponse).isNotNull();
assertThat(actualMeterReadsGasResponse.getConsumption()).isNotNull();
assertThat(actualMeterReadsGasResponse.getConsumption().getUnit()).isNotNull();
assertThat(actualMeterReadsGasResponse.getConsumption().getValue()).isNotNull();
assertThat(actualMeterReadsGasResponse.getConsumption().getUnit()).isEqualTo(OSGP_UNITTYPE);
assertThat(actualMeterReadsGasResponse.getConsumption().getValue()).isEqualTo(VALUE);
// For more information on the mapping of Date to XmlGregorianCalendar
// objects, refer to the DateMappingTest
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas in project open-smart-grid-platform by OSGP.
the class MeterReadsGasMappingTest method testWithNullDlmsMeterValueDto.
// Test mapping when DlmsMeterValue is null;
@Test
public void testWithNullDlmsMeterValueDto() {
// build test data
final DlmsMeterValueDto consumption = null;
final MeterReadsGasResponseDto meterReadsGasDto = new MeterReadsGasResponseDto(new Date(), consumption, new Date());
// actual mapping
final MeterReadsGas meterReadsGas = this.monitoringMapper.map(meterReadsGasDto, MeterReadsGas.class);
// test mapping
assertThat(meterReadsGas).isNotNull();
assertThat(meterReadsGas.getLogTime()).isEqualTo(meterReadsGasDto.getLogTime());
assertThat(meterReadsGas.getCaptureTime()).isEqualTo(meterReadsGasDto.getCaptureTime());
assertThat(meterReadsGas.getConsumption()).isNull();
}
Aggregations