Search in sources :

Example 1 with ProfileEntry

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry 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);
}
Also used : ObisCodeValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ObisCodeValues) ProfileEntry(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry) PowerQualityProfileData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData) GetPowerQualityProfileResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileResponse) CaptureObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject) Test(org.junit.jupiter.api.Test)

Example 2 with ProfileEntry

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

the class GetPowerQualityProfileResponseMappingTest method makeProfileEntries.

private List<ProfileEntry> makeProfileEntries() {
    final List<ProfileEntry> profileEntries = new ArrayList<>();
    profileEntries.add(this.makeProfileEntry(new DateTime(2017, 1, 1, 1, 0, 0, DateTimeZone.UTC).toDate(), "test1", new BigDecimal(1.1d), 111L));
    profileEntries.add(this.makeProfileEntry(new DateTime(2017, 2, 2, 2, 0, 0, DateTimeZone.UTC).toDate(), "test2", new BigDecimal(2.2d), 222L));
    return profileEntries;
}
Also used : ProfileEntry(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) BigDecimal(java.math.BigDecimal)

Example 3 with ProfileEntry

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

the class PowerQualityProfileResponseDataMappingTest method testConvertProfileEntryDto.

@Test
public void testConvertProfileEntryDto() {
    final ProfileEntry result = this.mapper.map(this.profileEntryDto(), ProfileEntry.class);
    assertThat(result).withFailMessage("mapping ProfileEntryDto should not return null").isNotNull();
    assertThat(result).withFailMessage("mapping ProfileEntryDto should return correct type").isOfAnyClassIn(ProfileEntry.class);
}
Also used : ProfileEntry(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry) Test(org.junit.jupiter.api.Test)

Example 4 with ProfileEntry

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry 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;
}
Also used : GetPowerQualityProfileResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileResponse) ObisCodeValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ObisCodeValues) PowerQualityProfileDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto) CaptureObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject) ProfileEntry(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry) ArrayList(java.util.ArrayList) PowerQualityProfileData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData)

Example 5 with ProfileEntry

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

the class GetPowerQualityProfileDtoConverter method makeProfileEntries.

private List<ProfileEntry> makeProfileEntries(final PowerQualityProfileDataDto responseDataDto) {
    final List<ProfileEntry> profileEntries = new ArrayList<>();
    for (final ProfileEntryDto profileEntryDto : responseDataDto.getProfileEntries()) {
        final List<ProfileEntryValue> profileEntryValues = new ArrayList<>();
        for (final ProfileEntryValueDto profileEntryValueDto : profileEntryDto.getProfileEntryValues()) {
            final ProfileEntryValue profileEntryValue = this.mapperFactory.getMapperFacade().map(profileEntryValueDto, ProfileEntryValue.class);
            profileEntryValues.add(profileEntryValue);
        }
        profileEntries.add(new ProfileEntry(profileEntryValues));
    }
    return profileEntries;
}
Also used : ProfileEntryValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto) ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) ProfileEntryValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue) ProfileEntry(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry) ArrayList(java.util.ArrayList)

Aggregations

ProfileEntry (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry)5 ArrayList (java.util.ArrayList)3 Test (org.junit.jupiter.api.Test)2 CaptureObject (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject)2 GetPowerQualityProfileResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileResponse)2 ObisCodeValues (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ObisCodeValues)2 PowerQualityProfileData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData)2 BigDecimal (java.math.BigDecimal)1 DateTime (org.joda.time.DateTime)1 ProfileEntryValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue)1 PowerQualityProfileDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto)1 ProfileEntryDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto)1 ProfileEntryValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto)1