Search in sources :

Example 6 with FindEventsRequestDto

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);
    });
}
Also used : FindEventsRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) Test(org.junit.jupiter.api.Test)

Example 7 with FindEventsRequestDto

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));
}
Also used : FindEventsRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) EventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) Test(org.junit.jupiter.api.Test)

Aggregations

FindEventsRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto)7 Test (org.junit.jupiter.api.Test)5 AttributeAddress (org.openmuc.jdlms.AttributeAddress)3 DataObject (org.openmuc.jdlms.datatypes.DataObject)3 EventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto)3 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)2 ArrayList (java.util.ArrayList)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 DataObjectToEventListConverter (org.opensmartgridplatform.adapter.protocol.dlms.application.mapping.DataObjectToEventListConverter)1 DlmsObjectConfigConfiguration (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration)1 DlmsObjectConfigService (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService)1 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)1 ActionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionDto)1 BundleMessagesRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.BundleMessagesRequestDto)1 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)1 EventMessageDataResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)1