use of org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto in project open-smart-grid-platform by OSGP.
the class FindEventsCommandExecutorTest method testRetrievalOfEventsForWrongCombinationOfProtocolAndLogType.
@Test
void testRetrievalOfEventsForWrongCombinationOfProtocolAndLogType() {
// SETUP
this.findEventsRequestDto = new FindEventsRequestDto(EventLogCategoryDto.AUXILIARY_EVENT_LOG, DateTime.now().minusDays(70), DateTime.now());
when(this.getResult.getResultCode()).thenReturn(AccessResultCode.SUCCESS);
when(this.getResult.getResultData()).thenReturn(this.resultData);
when(this.resultData.getValue()).thenReturn(this.generateDataObjectsAuxiliary());
// CALL
assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> {
this.executor.execute(this.conn, this.DLMS_DEVICE_5_0, this.findEventsRequestDto, this.messageMetadata);
});
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto in project open-smart-grid-platform by OSGP.
the class FindEventsCommandExecutorTest method testRetrievalOfEventsFromPowerQualityExtendedEventLog.
@Test
void testRetrievalOfEventsFromPowerQualityExtendedEventLog() throws ProtocolAdapterException, IOException {
// SETUP
this.findEventsRequestDto = new FindEventsRequestDto(EventLogCategoryDto.POWER_QUALITY_EXTENDED_EVENT_LOG, DateTime.now().minusDays(70), DateTime.now());
when(this.getResult.getResultCode()).thenReturn(AccessResultCode.SUCCESS);
when(this.getResult.getResultData()).thenReturn(this.resultData);
when(this.resultData.getValue()).thenReturn(this.generateDataObjectsExtendedPowerQuality());
// CALL
final List<EventDto> events = this.executor.execute(this.conn, this.DLMS_DEVICE_5_2, this.findEventsRequestDto, this.messageMetadata);
// VERIFY
assertThat(events.size()).isEqualTo(6);
int firstEventCode = 93;
for (final EventDto event : events) {
assertThat(event.getEventCode()).isEqualTo(firstEventCode++);
}
verify(this.dlmsHelper, times(events.size())).convertDataObjectToDateTime(any(DataObject.class));
verify(this.conn).getDlmsMessageListener();
verify(this.conn).getConnection();
verify(this.dlmsConnection).get(any(AttributeAddress.class));
}
Aggregations