Search in sources :

Example 1 with PeriodicMeterReadsContainer

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());
}
Also used : PeriodicMeterReadsContainer(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer) ArrayList(java.util.ArrayList) PeriodicMeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads) PeriodicMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse) Test(org.junit.jupiter.api.Test)

Example 2 with PeriodicMeterReadsContainer

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

Example 3 with PeriodicMeterReadsContainer

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
}
Also used : AmrProfileStatusCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode) TreeSet(java.util.TreeSet) PeriodicMeterReadsContainer(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer) ArrayList(java.util.ArrayList) AmrProfileStatusCodeFlag(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag) PeriodicMeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads) PeriodicMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) Test(org.junit.jupiter.api.Test)

Example 4 with PeriodicMeterReadsContainer

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());
}
Also used : PeriodicMeterReadsResponseItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseItemDto) PeriodTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto) PeriodicMeterReadsContainer(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer) ArrayList(java.util.ArrayList) PeriodicMeterReadsResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseDto) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)4 Test (org.junit.jupiter.api.Test)4 PeriodicMeterReadsContainer (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer)4 TreeSet (java.util.TreeSet)2 PeriodicMeterReadsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse)2 PeriodicMeterReads (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads)2 PeriodTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto)2 PeriodicMeterReadsResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseDto)2 PeriodicMeterReadsResponseItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseItemDto)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