use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileDataMapperTest method shouldConvertValueObjectToDto.
@Test
public void shouldConvertValueObjectToDto() {
final GetPowerQualityProfileRequestData source = new GetPowerQualityProfileRequestData("PUBLIC", BEGIN_DATE.toDate(), END_DATE.toDate());
final GetPowerQualityProfileRequestDataDto result = this.mapper.map(source, GetPowerQualityProfileRequestDataDto.class);
assertThat(result.getBeginDate()).withFailMessage(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(BEGIN_DATE.toDate());
assertThat(result.getEndDate()).withFailMessage(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(END_DATE.toDate());
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageListenerIT method testProcessRequestMessages.
@Test
void testProcessRequestMessages() throws JMSException, OsgpException {
// SETUP
final DlmsDevice dlmsDevice = new DlmsDevice();
dlmsDevice.setDeviceIdentification("1");
dlmsDevice.setIpAddress("127.0.0.1");
dlmsDevice.setHls5Active(true);
when(this.domainHelperService.findDlmsDevice(any(MessageMetadata.class))).thenReturn(dlmsDevice);
doNothing().when(this.protocolDlmsOutboundOsgpCoreResponsesMessageSender).send(any(ResponseMessage.class));
// EXECUTE
LOGGER.info("Starting Test");
for (int i = 0; i < 200; i++) {
LOGGER.info("Send message number {} ", i);
final ObjectMessage message = new ObjectMessageBuilder().withDeviceIdentification("osgp").withMessageType(MessageType.GET_PROFILE_GENERIC_DATA.toString()).withObject(new GetPowerQualityProfileRequestDataDto("PUBLIC", new Date(), new Date(), null)).build();
this.listener.onMessage(message);
}
verify(this.protocolDlmsOutboundOsgpCoreResponsesMessageSender, times(200)).send(any(ResponseMessage.class));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto 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.GetPowerQualityProfileRequestDataDto 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);
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(GetPowerQualityProfileRequestDataDto.class, requestObject);
final GetPowerQualityProfileRequestDataDto getPowerQualityProfileRequestDataDto = (GetPowerQualityProfileRequestDataDto) requestObject;
return this.monitoringService.requestPowerQualityProfile(conn, device, getPowerQualityProfileRequestDataDto, messageMetadata);
}
Aggregations