Search in sources :

Example 1 with ActiveEnergyValues

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

the class MeterReadsMappingTest method testMeterReadsMapping.

/**
 * Tests if a MeterReads object can be mapped.
 */
@Test
public void testMeterReadsMapping() {
    // build test data
    final OsgpMeterValue osgpMeterValue = new OsgpMeterValue(VALUE, OSGP_UNIT);
    final MeterReads meterReads = new MeterReads(DATE, new ActiveEnergyValues(osgpMeterValue, osgpMeterValue, osgpMeterValue, osgpMeterValue, osgpMeterValue, osgpMeterValue));
    // actual mapping
    final ActualMeterReadsResponse actualMeterReadsResponse = this.monitoringMapper.map(meterReads, ActualMeterReadsResponse.class);
    // check mapping
    assertThat(actualMeterReadsResponse).isNotNull();
    assertThat(actualMeterReadsResponse.getLogTime()).isNotNull();
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyExport());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyExportTariffOne());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyExportTariffTwo());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyImport());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyImportTariffOne());
    this.checkOsgpMeterValueMapping(actualMeterReadsResponse.getActiveEnergyImportTariffTwo());
// For more information on the mapping of Date to XmlGregorianCalendar
// objects, refer to the DateMappingTest
}
Also used : ActualMeterReadsResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse) MeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReads) ActiveEnergyValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues) OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) Test(org.junit.jupiter.api.Test)

Example 2 with ActiveEnergyValues

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

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

the class MonitoringMapperTest method convertsMeterReadsResponseDtoToMeterReads.

@Test
public void convertsMeterReadsResponseDtoToMeterReads() {
    final Date logTime = new Date(123L * 24 * 60 * 60 * 1000);
    final ActiveEnergyValuesDto activeEnergyValuesDto = 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 MeterReadsResponseDto source = new MeterReadsResponseDto(logTime, activeEnergyValuesDto);
    final MeterReads result = this.mapper.map(source, MeterReads.class);
    final ActiveEnergyValues activeEnergyValues = 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 MeterReads expected = new MeterReads(logTime, activeEnergyValues);
    assertThat(result).usingRecursiveComparison().isEqualTo(expected);
}
Also used : MeterReadsResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MeterReadsResponseDto) MeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReads) 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 ActiveEnergyValues

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

the class MeterReadsResponseItemDtoConverter method convert.

@Override
public MeterReads convert(final MeterReadsResponseDto source, final Type<? extends MeterReads> 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()));
    return new MeterReads(logTime, activeEnergyValues);
}
Also used : MeterReads(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReads) ActiveEnergyValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues) Date(java.util.Date)

Example 5 with ActiveEnergyValues

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

ActiveEnergyValues (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues)5 Date (java.util.Date)4 Test (org.junit.jupiter.api.Test)3 MeterReads (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReads)3 OsgpMeterValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue)3 BigDecimal (java.math.BigDecimal)2 AmrProfileStatusCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode)2 PeriodicMeterReads (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReads)2 ActiveEnergyValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActiveEnergyValuesDto)2 DlmsMeterValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DlmsMeterValueDto)2 ActualMeterReadsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse)1 AmrProfileStatusCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AmrProfileStatusCodeDto)1 MeterReadsResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MeterReadsResponseDto)1 PeriodicMeterReadsResponseItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseItemDto)1