Search in sources :

Example 1 with PeriodicMeterReads

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads 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 PeriodicMeterReads

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads 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 3 with PeriodicMeterReads

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

the class PeriodicMeterReadContainerMappingTest method mapsPeriodicMeterReadsResponseItemDto.

@Test
public void mapsPeriodicMeterReadsResponseItemDto() {
    final Date logTime = new Date();
    final ActiveEnergyValuesDto valuesDto = new ActiveEnergyValuesDto(new DlmsMeterValueDto(new BigDecimal("12.34"), DlmsUnitTypeDto.M3), new DlmsMeterValueDto(new BigDecimal("12.35"), DlmsUnitTypeDto.M3), new DlmsMeterValueDto(new BigDecimal("12.36"), DlmsUnitTypeDto.M3), new DlmsMeterValueDto(new BigDecimal("12.37"), DlmsUnitTypeDto.M3), new DlmsMeterValueDto(new BigDecimal("12.38"), DlmsUnitTypeDto.M3), new DlmsMeterValueDto(new BigDecimal("12.39"), DlmsUnitTypeDto.M3));
    final AmrProfileStatusCodeDto amrProfileStatusCodeDto = new AmrProfileStatusCodeDto(new HashSet<>(asList(AmrProfileStatusCodeFlagDto.CRITICAL_ERROR, AmrProfileStatusCodeFlagDto.CLOCK_ADJUSTED)));
    final PeriodicMeterReadsResponseItemDto source = new PeriodicMeterReadsResponseItemDto(logTime, valuesDto, amrProfileStatusCodeDto);
    final PeriodicMeterReads readsResult = this.monitoringMapper.map(source, PeriodicMeterReads.class);
    final ActiveEnergyValues expectedValues = new ActiveEnergyValues(new OsgpMeterValue(new BigDecimal("12.340"), OsgpUnit.M3), new OsgpMeterValue(new BigDecimal("12.350"), OsgpUnit.M3), new OsgpMeterValue(new BigDecimal("12.360"), OsgpUnit.M3), new OsgpMeterValue(new BigDecimal("12.370"), OsgpUnit.M3), new OsgpMeterValue(new BigDecimal("12.380"), OsgpUnit.M3), new OsgpMeterValue(new BigDecimal("12.390"), OsgpUnit.M3));
    final AmrProfileStatusCode amrProfileStatusCode = new AmrProfileStatusCode(new HashSet<>(asList(AmrProfileStatusCodeFlag.CRITICAL_ERROR, AmrProfileStatusCodeFlag.CLOCK_ADJUSTED)));
    final PeriodicMeterReads expectedReads = new PeriodicMeterReads(logTime, expectedValues, amrProfileStatusCode);
    assertThat(readsResult).usingRecursiveComparison().isEqualTo(expectedReads);
}
Also used : AmrProfileStatusCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AmrProfileStatusCodeDto) PeriodicMeterReadsResponseItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseItemDto) AmrProfileStatusCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode) PeriodicMeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads) ActiveEnergyValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActiveEnergyValuesDto) ActiveEnergyValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues) Date(java.util.Date) BigDecimal(java.math.BigDecimal) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) DlmsMeterValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto) Test(org.junit.jupiter.api.Test)

Example 4 with PeriodicMeterReads

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

the class PeriodicMeterReadsResponseItemDtoConverter method convert.

@Override
public PeriodicMeterReads convert(final PeriodicMeterReadsResponseItemDto source, final Type<? extends PeriodicMeterReads> destinationType, final MappingContext mappingContext) {
    final Date logTime = source.getLogTime();
    final ActiveEnergyValues activeEnergyValues = new ActiveEnergyValues(this.toOsgpMeterValue(source.getActiveEnergyImport()), this.toOsgpMeterValue(source.getActiveEnergyExport()), this.toOsgpMeterValue(source.getActiveEnergyImportTariffOne()), this.toOsgpMeterValue(source.getActiveEnergyImportTariffTwo()), this.toOsgpMeterValue(source.getActiveEnergyExportTariffOne()), this.toOsgpMeterValue(source.getActiveEnergyExportTariffTwo()));
    final AmrProfileStatusCode amrProfileStatusCode = this.toAmrProfileStatusCode(source.getAmrProfileStatusCode());
    return new PeriodicMeterReads(logTime, activeEnergyValues, amrProfileStatusCode);
}
Also used : AmrProfileStatusCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode) PeriodicMeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads) ActiveEnergyValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues) Date(java.util.Date)

Aggregations

PeriodicMeterReads (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads)4 Test (org.junit.jupiter.api.Test)3 AmrProfileStatusCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 PeriodicMeterReadsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse)2 ActiveEnergyValues (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues)2 OsgpMeterValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue)2 PeriodicMeterReadsContainer (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer)2 BigDecimal (java.math.BigDecimal)1 TreeSet (java.util.TreeSet)1 AmrProfileStatusCodeFlag (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag)1 ActiveEnergyValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActiveEnergyValuesDto)1 AmrProfileStatusCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AmrProfileStatusCodeDto)1 DlmsMeterValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto)1 PeriodicMeterReadsResponseItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseItemDto)1