use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntryValue in project open-smart-grid-platform by OSGP.
the class PowerQualityProfileDataMappingTest method testProfileEntry.
@Test
public void testProfileEntry() {
org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue profileEntryValueVo = new org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue("test");
ProfileEntryValue profileEntryValue = this.monitoringMapper.map(profileEntryValueVo, ProfileEntryValue.class);
assertThat(profileEntryValue.getStringValueOrDateValueOrFloatValue().get(0)).isEqualTo("test");
profileEntryValueVo = new org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue(new Date());
profileEntryValue = this.monitoringMapper.map(profileEntryValueVo, ProfileEntryValue.class);
assertThat(profileEntryValue.getStringValueOrDateValueOrFloatValue().get(0)).isInstanceOf(XMLGregorianCalendar.class);
profileEntryValueVo = new org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue(new BigDecimal(100.0d));
profileEntryValue = this.monitoringMapper.map(profileEntryValueVo, ProfileEntryValue.class);
assertThat(((BigDecimal) profileEntryValue.getStringValueOrDateValueOrFloatValue().get(0)).doubleValue() == 100.d).isTrue();
profileEntryValueVo = new org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue(12345L);
profileEntryValue = this.monitoringMapper.map(profileEntryValueVo, ProfileEntryValue.class);
assertThat(((Long) profileEntryValue.getStringValueOrDateValueOrFloatValue().get(0)).doubleValue() == 12345L).isTrue();
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntryValue 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.adapter.ws.schema.smartmetering.common.ProfileEntryValue in project open-smart-grid-platform by OSGP.
the class ProfileEntryValueConverter method convert.
@Override
public ProfileEntryValue convert(final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue source, final Type<? extends ProfileEntryValue> destinationType, final MappingContext context) {
final ProfileEntryValue result = new ProfileEntryValue();
if (source.getValue() instanceof Date) {
final XMLGregorianCalendar xmlGregCal = this.mapperFacade.map(source.getValue(), XMLGregorianCalendar.class);
result.getStringValueOrDateValueOrFloatValue().add(xmlGregCal);
} else {
result.getStringValueOrDateValueOrFloatValue().add(source.getValue());
}
return result;
}
Aggregations