Search in sources :

Example 1 with OsgpMeterValue

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

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

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

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

the class MeterValueConverter method convert.

@Override
public MeterValue convert(final OsgpMeterValue source, final Type<? extends MeterValue> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final MeterValue m = new MeterValue();
    m.setValue(source.getValue());
    m.setUnit(OsgpUnitType.fromValue(source.getOsgpUnit().name()));
    return m;
}
Also used : OsgpMeterValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue) MeterValue(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.MeterValue)

Example 5 with OsgpMeterValue

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

Aggregations

OsgpMeterValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.OsgpMeterValue)8 Test (org.junit.jupiter.api.Test)6 BigDecimal (java.math.BigDecimal)3 ActiveEnergyValues (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActiveEnergyValues)3 AmrProfileStatusCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCode)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 TreeSet (java.util.TreeSet)2 AmrProfileStatusCodeFlag (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AmrProfileStatusCodeFlag)2 MeterReads (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReads)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 ActualMeterReadsGasResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsGasResponse)1 ActualMeterReadsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualMeterReadsResponse)1 MeterValue (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.MeterValue)1 PeriodicMeterReadsGasResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsGasResponse)1 PeriodicMeterReadsResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PeriodicMeterReadsResponse)1 MeterReadsGas (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.MeterReadsGas)1 PeriodicMeterReadsContainer (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PeriodicMeterReadsContainer)1