use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData 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.PowerQualityProfileData in project open-smart-grid-platform by OSGP.
the class PowerQualityProfileDataMappingTest method testPowerQualityProfileDataResponse.
@Test
public void testPowerQualityProfileDataResponse() {
final PowerQualityProfileData source = this.makeresponseVo();
final org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityProfileData target = this.monitoringMapper.map(source, org.opensmartgridplatform.adapter.ws.schema.smartmetering.monitoring.PowerQualityProfileData.class);
assertThat(target).as("mapping GetPowerQualityProfileResponseData should not return null").isNotNull();
Assertions.assertThat(target.getCaptureObjectList().getCaptureObjects().size()).isEqualTo(1);
Assertions.assertThat(target.getProfileEntryList().getProfileEntries().get(0).getProfileEntryValue()).isNotNull();
Assertions.assertThat(target.getProfileEntryList().getProfileEntries().get(0).getProfileEntryValue().size()).isEqualTo(4);
int i = 0;
for (final ProfileEntryValue profileEntryValue : target.getProfileEntryList().getProfileEntries().get(0).getProfileEntryValue()) {
assertThat(profileEntryValue.getStringValueOrDateValueOrFloatValue()).isNotNull();
assertThat(profileEntryValue.getStringValueOrDateValueOrFloatValue().size()).isEqualTo(1);
final Class<?> clazz = profileEntryValue.getStringValueOrDateValueOrFloatValue().get(0).getClass();
assertThat(clazz.getSimpleName()).isEqualTo(EXPECTED_CLASS[i++]);
assertThat(profileEntryValue.getStringValueOrDateValueOrFloatValue() != null && !profileEntryValue.getStringValueOrDateValueOrFloatValue().isEmpty()).isTrue();
}
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData 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.PowerQualityProfileData in project open-smart-grid-platform by OSGP.
the class PowerQualityProfileResponseDataMapperTest method testConvertGetPowerQualityProfileResponseVo.
@Test
public void testConvertGetPowerQualityProfileResponseVo() {
final PowerQualityProfileDataDto responseDto = this.makeResponseDataDto();
final PowerQualityProfileData responseVo = this.mapper.map(responseDto, PowerQualityProfileData.class);
assertThat(responseVo).withFailMessage("response object should not be null").isNotNull();
assertThat(responseVo.getProfileEntries().get(0).getProfileEntryValues().size()).withFailMessage("response object should return same number of profilentries").isEqualTo(EXPECTED_CLASS.length);
int i = 0;
for (final ProfileEntryValue profileEntryValueVo : responseVo.getProfileEntries().get(0).getProfileEntryValues()) {
final Class<?> clazz = profileEntryValueVo.getValue().getClass();
assertThat(clazz).withFailMessage("the return class should be of the same type").isEqualTo(EXPECTED_CLASS[i++]);
}
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData in project open-smart-grid-platform by OSGP.
the class PowerQualityProfileResponseDataMappingTest method testConvertGetPowerQualityProfileResponseDto.
@Test
public void testConvertGetPowerQualityProfileResponseDto() {
final PowerQualityProfileDataDto dto = this.makePowerQualityProfileResponseDataDto();
final PowerQualityProfileData result = this.mapper.map(dto, PowerQualityProfileData.class);
assertThat(result).withFailMessage("mapping GetPowerQualityProfileResponseData should not return null").isNotNull();
assertThat(result).withFailMessage("mapping GetPowerQualityProfileResponseData should return correct type").isOfAnyClassIn(PowerQualityProfileData.class);
}
Aggregations