Search in sources :

Example 1 with ActualPowerQualityData

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

the class ActualPowerQualityDtoConverter method convert.

@Override
public ActualPowerQualityResponse convert(final ActualPowerQualityResponseDto source, final Type<? extends ActualPowerQualityResponse> destinationType, final MappingContext mappingContext) {
    if (source.getActualPowerQualityData() != null) {
        final ActualPowerQualityDataDto responseDataDto = source.getActualPowerQualityData();
        final List<PowerQualityObject> powerQualityObjects = new ArrayList<>(this.mapperFacade.mapAsList(responseDataDto.getPowerQualityObjects(), PowerQualityObject.class));
        final List<PowerQualityValue> powerQualityValues = this.makePowerQualityValues(responseDataDto);
        final ActualPowerQualityData actualPowerQualityData = new ActualPowerQualityData(powerQualityObjects, powerQualityValues);
        return new ActualPowerQualityResponse(actualPowerQualityData);
    } else {
        return new ActualPowerQualityResponse(null);
    }
}
Also used : ActualPowerQualityData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityData) ActualPowerQualityDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityDataDto) PowerQualityObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityObject) ActualPowerQualityResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityResponse) ArrayList(java.util.ArrayList) PowerQualityValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityValue)

Example 2 with ActualPowerQualityData

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

the class ActualPowerQualityResponseDataMapperTest method testConvertActualPowerQualityResponse.

@Test
public void testConvertActualPowerQualityResponse() {
    final ActualPowerQualityDataDto responseDto = new ActualPowerQualityDataDto(new ArrayList<PowerQualityObjectDto>(), this.makePowerQualityValueDtos());
    final ActualPowerQualityData response = this.mapper.map(responseDto, ActualPowerQualityData.class);
    assertThat(response).isNotNull();
    assertThat(response.getPowerQualityValues()).hasSize(EXPECTED_CLASS.length);
    int i = 0;
    for (final PowerQualityValue powerQualityValue : response.getPowerQualityValues()) {
        final Class<?> clazz = powerQualityValue.getValue().getClass();
        assertThat(clazz).withFailMessage("the return class should be of the same type").isEqualTo(EXPECTED_CLASS[i++]);
    }
}
Also used : ActualPowerQualityData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityData) ActualPowerQualityDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityDataDto) PowerQualityValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityValue) PowerQualityObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityObjectDto) Test(org.junit.jupiter.api.Test)

Example 3 with ActualPowerQualityData

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

the class ActualPowerQualityResponseDataConverter method convert.

@Override
public org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityData convert(final ActualPowerQualityData source, final Type<? extends org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityData> destinationType, final MappingContext mappingContext) {
    if (source == null) {
        return null;
    }
    final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityData result = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityData();
    final PowerQualityObjects powerQualityObjects = new PowerQualityObjects();
    powerQualityObjects.getPowerQualityObject().addAll(this.mapperFacade.mapAsList(source.getPowerQualityObjects(), PowerQualityObject.class));
    result.setPowerQualityObjects(powerQualityObjects);
    final PowerQualityValues powerQualityValues = new PowerQualityValues();
    powerQualityValues.getPowerQualityValue().addAll(this.mapPowerQualityValues(source));
    result.setPowerQualityValues(powerQualityValues);
    return result;
}
Also used : ActualPowerQualityData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityData) PowerQualityObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityObject) PowerQualityObjects(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityObjects) PowerQualityValues(org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityValues)

Example 4 with ActualPowerQualityData

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

the class ActualPowerQualityResponseMappingTest method shouldConvertActualPowerQualityResponse.

@Test
public void shouldConvertActualPowerQualityResponse() {
    // Arrange
    final List<PowerQualityObject> powerQualityObjects = this.makePowerQualityObjects();
    final List<PowerQualityValue> powerQualityValues = this.makePowerQualityValues();
    final ActualPowerQualityData responseData = new ActualPowerQualityData(powerQualityObjects, powerQualityValues);
    final ActualPowerQualityResponse source = new ActualPowerQualityResponse(responseData);
    // Act
    final org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.ActualPowerQualityResponse target = this.monitoringMapper.map(source, org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.ActualPowerQualityResponse.class);
    // Assert
    final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.ActualPowerQualityData mappedResponseData = target.getActualPowerQualityData();
    this.assertPowerQualityObjects(mappedResponseData.getPowerQualityObjects().getPowerQualityObject(), powerQualityObjects);
    this.assertPowerQualityValues(mappedResponseData.getPowerQualityValues().getPowerQualityValue(), powerQualityValues);
}
Also used : PowerQualityObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityObject) ActualPowerQualityResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityResponse) ActualPowerQualityData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityData) PowerQualityValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityValue) Test(org.junit.jupiter.api.Test)

Aggregations

ActualPowerQualityData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityData)4 PowerQualityValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityValue)3 Test (org.junit.jupiter.api.Test)2 ActualPowerQualityResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActualPowerQualityResponse)2 PowerQualityObject (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityObject)2 ActualPowerQualityDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityDataDto)2 ArrayList (java.util.ArrayList)1 PowerQualityObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityObject)1 PowerQualityObjects (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityObjects)1 PowerQualityValues (org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityValues)1 PowerQualityObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityObjectDto)1