use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileResponseMappingTest method shouldConvertGetPowerQualityProfileResponse.
@Test
public void shouldConvertGetPowerQualityProfileResponse() {
// Arrange
final ObisCodeValues obisCode = this.makeObisCode();
final List<CaptureObject> captureObjects = this.makeCaptureObjects();
final List<ProfileEntry> profileEntries = this.makeProfileEntries();
final PowerQualityProfileData responseData = new PowerQualityProfileData(obisCode, captureObjects, profileEntries);
final GetPowerQualityProfileResponse source = new GetPowerQualityProfileResponse();
source.setPowerQualityProfileDatas(Collections.singletonList(responseData));
// Act
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetPowerQualityProfileResponse target = this.monitoringMapper.map(source, org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetPowerQualityProfileResponse.class);
// Assert
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityProfileData mappedResponseData = target.getPowerQualityProfileDatas().get(0);
this.assertObisCode(mappedResponseData.getLogicalName(), obisCode);
this.assertCaptureObjects(mappedResponseData.getCaptureObjectList().getCaptureObjects(), captureObjects);
this.assertProfileEntries(mappedResponseData.getProfileEntryList().getProfileEntries(), profileEntries);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileDtoConverter method convert.
@Override
public GetPowerQualityProfileResponse convert(final GetPowerQualityProfileResponseDto source, final Type<? extends GetPowerQualityProfileResponse> destinationType, final MappingContext mappingContext) {
final GetPowerQualityProfileResponse response = new GetPowerQualityProfileResponse();
final List<PowerQualityProfileData> powerQualityProfileDatas = new ArrayList<>();
for (final PowerQualityProfileDataDto responseDataDto : source.getPowerQualityProfileResponseDatas()) {
final ObisCodeValues obisCodeValues = this.mapperFactory.getMapperFacade().map(responseDataDto.getLogicalName(), ObisCodeValues.class);
final List<CaptureObject> captureObjects = new ArrayList<>(this.mapperFacade.mapAsList(responseDataDto.getCaptureObjects(), CaptureObject.class));
final List<ProfileEntry> profileEntries = this.makeProfileEntries(responseDataDto);
powerQualityProfileDatas.add(new PowerQualityProfileData(obisCodeValues, captureObjects, profileEntries));
}
response.setPowerQualityProfileDatas(powerQualityProfileDatas);
return response;
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject in project open-smart-grid-platform by OSGP.
the class PowerQualityProfileResponseDataMappingTest method testConvertcaptureObjectDto.
@Test
public void testConvertcaptureObjectDto() {
final CaptureObject result = this.mapper.map(this.captureObjectDto(), CaptureObject.class);
assertThat(result).withFailMessage("mapping CaptureObjectDto should not return null").isNotNull();
assertThat(result).withFailMessage("mapping CaptureObjectDto should return correct type").isOfAnyClassIn(CaptureObject.class);
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileResponseMappingTest method makeCaptureObjects.
private List<CaptureObject> makeCaptureObjects() {
final List<CaptureObject> captureObjects = new ArrayList<>();
captureObjects.add(new CaptureObject(8L, "0.0.1.0.0.255", 2, 0, OsgpUnitType.UNDEFINED.name()));
captureObjects.add(new CaptureObject(3L, "1.1.1.0.0.255", 2, 0, OsgpUnitType.W.name()));
captureObjects.add(new CaptureObject(3L, "2.2.2.0.0.255", 2, 0, OsgpUnitType.W.name()));
captureObjects.add(new CaptureObject(4L, "3.3.3.0.0.255", 2, 0, OsgpUnitType.W.name()));
return captureObjects;
}
Aggregations