Search in sources :

Example 1 with MeterReadsGas

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);
}
Also used : MeterReadsGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas) MeterReadsGasResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MeterReadsGasResponseDto) BigDecimal(java.math.BigDecimal) Date(java.util.Date) DlmsMeterValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto) Test(org.junit.jupiter.api.Test)

Example 2 with MeterReadsGas

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
}
Also used : MeterReadsGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas) ActualMeterReadsGasResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsGasResponse) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) Test(org.junit.jupiter.api.Test)

Example 3 with MeterReadsGas

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();
}
Also used : MeterReadsGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas) MeterReadsGasResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MeterReadsGasResponseDto) Date(java.util.Date) DlmsMeterValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 MeterReadsGas (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas)3 Date (java.util.Date)2 DlmsMeterValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto)2 MeterReadsGasResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MeterReadsGasResponseDto)2 BigDecimal (java.math.BigDecimal)1 ActualMeterReadsGasResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsGasResponse)1 OsgpMeterValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue)1