Search in sources :

Example 1 with ProfileEntryValue

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();
}
Also used : ProfileEntryValue(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntryValue) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test)

Example 2 with ProfileEntryValue

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();
    }
}
Also used : ProfileEntryValue(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntryValue) PowerQualityProfileData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData) Test(org.junit.jupiter.api.Test)

Example 3 with ProfileEntryValue

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ProfileEntryValue(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntryValue) Date(java.util.Date)

Aggregations

ProfileEntryValue (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ProfileEntryValue)3 Date (java.util.Date)2 Test (org.junit.jupiter.api.Test)2 BigDecimal (java.math.BigDecimal)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 PowerQualityProfileData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData)1