Search in sources :

Example 1 with PeriodicMeterReadsContainerGas

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas 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());
}
Also used : PeriodTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto) PeriodicMeterReadsGasResponseItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsGasResponseItemDto) ArrayList(java.util.ArrayList) PeriodicMeterReadGasResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadGasResponseDto) PeriodicMeterReadsContainerGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas) Test(org.junit.jupiter.api.Test)

Example 2 with PeriodicMeterReadsContainerGas

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas 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();
}
Also used : AmrProfileStatusCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AmrProfileStatusCodeDto) PeriodTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto) PeriodicMeterReadsGasResponseItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsGasResponseItemDto) AmrProfileStatusCodeFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AmrProfileStatusCodeFlagDto) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) Date(java.util.Date) TreeSet(java.util.TreeSet) PeriodicMeterReadGasResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadGasResponseDto) PeriodicMeterReadsContainerGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas) DlmsMeterValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto) Test(org.junit.jupiter.api.Test)

Example 3 with PeriodicMeterReadsContainerGas

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas in project open-smart-grid-platform by OSGP.

the class PeriodicMeterReadsContainerGasMappingTest method testWithFilledList.

/**
 * Tests if mapping a PeriodicMeterReadsContainerGas object with a filled List and Set succeeds.
 */
@Test
public void testWithFilledList() {
    // 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 PeriodicMeterReadsGas periodicMeterReadsGas = new PeriodicMeterReadsGas(DATE, osgpMeterValue, DATE, amrProfileStatusCode);
    final List<PeriodicMeterReadsGas> periodicMeterReadsList = new ArrayList<>();
    periodicMeterReadsList.add(periodicMeterReadsGas);
    final PeriodicMeterReadsContainerGas periodicMeterReadsContainer = new PeriodicMeterReadsContainerGas(PERIODTYPE, periodicMeterReadsList);
    // actual mapping
    final PeriodicMeterReadsGasResponse periodicMeterReadsResponseGas = this.monitoringMapper.map(periodicMeterReadsContainer, PeriodicMeterReadsGasResponse.class);
    // check mapping
    assertThat(periodicMeterReadsResponseGas).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0)).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlag()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getAmrProfileStatusCode().getAmrProfileStatusCodeFlag().get(0)).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getUnit()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getValue()).isNotNull();
    assertThat(periodicMeterReadsResponseGas.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().size()).isEqualTo(periodicMeterReadsList.size());
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getValue()).isEqualTo(VALUE);
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().get(0).getConsumption().getUnit()).isEqualTo(OSGP_UNITTYPE);
    assertThat(periodicMeterReadsResponseGas.getPeriodicMeterReadsGas().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
}
Also used : PeriodicMeterReadsGasResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse) AmrProfileStatusCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) AmrProfileStatusCodeFlag(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag) PeriodicMeterReadsGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsGas) PeriodicMeterReadsContainerGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) Test(org.junit.jupiter.api.Test)

Example 4 with PeriodicMeterReadsContainerGas

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas in project open-smart-grid-platform by OSGP.

the class PeriodicMeterReadsContainerGasMappingTest method testWithEmptyList.

/**
 * Tests if mapping a PeriodicMeterReadsContainerGas object with an empty list succeeds.
 */
@Test
public void testWithEmptyList() {
    // build test data
    final List<PeriodicMeterReadsGas> periodicMeterReadsGasList = new ArrayList<>();
    final PeriodicMeterReadsContainerGas periodicMeterReadsContainerGas = new PeriodicMeterReadsContainerGas(PERIODTYPE, periodicMeterReadsGasList);
    // actual mapping
    final PeriodicMeterReadsGasResponse periodicMeterReadsGasResponse = this.monitoringMapper.map(periodicMeterReadsContainerGas, PeriodicMeterReadsGasResponse.class);
    // check mapping
    assertThat(periodicMeterReadsGasResponse).isNotNull();
    assertThat(periodicMeterReadsGasResponse.getPeriodicMeterReadsGas()).isNotNull();
    assertThat(periodicMeterReadsGasResponse.getPeriodType()).isNotNull();
    assertThat(periodicMeterReadsGasResponse.getPeriodicMeterReadsGas().isEmpty()).isTrue();
    assertThat(periodicMeterReadsGasResponse.getPeriodType().name()).isEqualTo(PERIODTYPE.name());
}
Also used : PeriodicMeterReadsGasResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse) ArrayList(java.util.ArrayList) PeriodicMeterReadsGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsGas) PeriodicMeterReadsContainerGas(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)4 Test (org.junit.jupiter.api.Test)4 PeriodicMeterReadsContainerGas (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainerGas)4 TreeSet (java.util.TreeSet)2 PeriodicMeterReadsGasResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse)2 PeriodicMeterReadsGas (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsGas)2 PeriodTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto)2 PeriodicMeterReadGasResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadGasResponseDto)2 PeriodicMeterReadsGasResponseItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsGasResponseItemDto)2 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 AmrProfileStatusCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode)1 AmrProfileStatusCodeFlag (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag)1 OsgpMeterValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue)1 AmrProfileStatusCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AmrProfileStatusCodeDto)1 AmrProfileStatusCodeFlagDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AmrProfileStatusCodeFlagDto)1 DlmsMeterValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto)1