use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto in project open-smart-grid-platform by OSGP.
the class PowerQualityProfileResponseDataMapperTest method makeProfileEntryDtos.
private List<ProfileEntryDto> makeProfileEntryDtos() {
final List<ProfileEntryDto> result = new ArrayList<>();
result.add(new ProfileEntryDto(this.makeProfileEntryValueDtos()));
return result;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto in project open-smart-grid-platform by OSGP.
the class AbstractGetPowerQualityProfileHandler method createProfileEntries.
private List<ProfileEntryDto> createProfileEntries(final List<GetResult> bufferList, final List<ScalerUnitInfo> scalerUnitInfos, final Map<Integer, CaptureObjectDefinitionDto> selectableCaptureObjects, final int timeInterval) {
final List<ProfileEntryDto> profileEntryDtos = new ArrayList<>();
// there is always only one GetResult, which is an array of array data
for (final GetResult buffer : bufferList) {
final DataObject dataObject = buffer.getResultData();
final List<DataObject> dataObjectValue = dataObject.getValue();
ProfileEntryDto previousProfileEntryDto = null;
for (final DataObject profileEntryDataObject : dataObjectValue) {
final ProfileEntryDto profileEntryDto = new ProfileEntryDto(this.createProfileEntryValueDto(profileEntryDataObject, scalerUnitInfos, previousProfileEntryDto, selectableCaptureObjects, timeInterval));
profileEntryDtos.add(profileEntryDto);
previousProfileEntryDto = profileEntryDto;
}
}
return profileEntryDtos;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto 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;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileNoSelectiveAccessHandlerTest method testHandlePublicProfileWithoutSelectiveAccess.
@Test
public void testHandlePublicProfileWithoutSelectiveAccess() throws ProtocolAdapterException {
// SETUP
final GetPowerQualityProfileRequestDataDto requestDto = new GetPowerQualityProfileRequestDataDto("PUBLIC", Date.from(Instant.now().minus(2, ChronoUnit.DAYS)), new Date(), new ArrayList<>());
when(this.dlmsHelper.getAndCheck(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(String.class), any(AttributeAddress.class))).thenReturn(this.createPartialNotAllowedCaptureObjects(), this.createProfileEntries(), this.createPartialNotAllowedCaptureObjects(), this.createProfileEntries());
when(this.dlmsHelper.readLogicalName(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.readObjectDefinition(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.readLongNotNull(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.readLong(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenCallRealMethod();
when(this.dlmsHelper.fromDateTimeValue(any())).thenCallRealMethod();
when(this.dlmsHelper.getClockDefinition()).thenCallRealMethod();
final GetPowerQualityProfileNoSelectiveAccessHandler handler = new GetPowerQualityProfileNoSelectiveAccessHandler(this.dlmsHelper);
// EXECUTE
final GetPowerQualityProfileResponseDto responseDto = handler.handle(this.conn, this.dlmsDevice, requestDto);
// ASSERT
assertThat(responseDto.getPowerQualityProfileResponseDatas().size()).isEqualTo(2);
assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getCaptureObjects().size()).isEqualTo(2);
assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries().size()).isEqualTo(4);
for (final ProfileEntryDto profileEntryDto : responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries()) {
assertThat(profileEntryDto.getProfileEntryValues().size()).isEqualTo(2);
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileSelectiveAccessHandlerTest method testHandlePrivateProfileSelectiveAccess.
@Test
public void testHandlePrivateProfileSelectiveAccess() throws ProtocolAdapterException {
// SETUP
final GetPowerQualityProfileRequestDataDto requestDto = new GetPowerQualityProfileRequestDataDto("PRIVATE", Date.from(Instant.now().minus(2, ChronoUnit.DAYS)), new Date(), new ArrayList<>());
when(this.dlmsHelper.getAndCheck(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(String.class), any(AttributeAddress.class))).thenReturn(this.createCaptureObjects(), this.createProfileEntries(), this.createCaptureObjectsProfile2(), this.createProfileEntries());
when(this.dlmsHelper.readLogicalName(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.readObjectDefinition(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.readLongNotNull(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.readLong(any(DataObject.class), any(String.class))).thenCallRealMethod();
when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenCallRealMethod();
when(this.dlmsHelper.fromDateTimeValue(any())).thenCallRealMethod();
when(this.dlmsHelper.getClockDefinition()).thenCallRealMethod();
final GetPowerQualityProfileSelectiveAccessHandler handler = new GetPowerQualityProfileSelectiveAccessHandler(this.dlmsHelper);
// EXECUTE
final GetPowerQualityProfileResponseDto responseDto = handler.handle(this.conn, this.dlmsDevice, requestDto);
// ASSERT
assertThat(responseDto.getPowerQualityProfileResponseDatas().size()).isEqualTo(2);
assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getCaptureObjects().size()).isEqualTo(3);
assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries().size()).isEqualTo(4);
for (final ProfileEntryDto profileEntryDto : responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries()) {
assertThat(profileEntryDto.getProfileEntryValues().size()).isEqualTo(3);
}
}
Aggregations