Search in sources :

Example 16 with EventDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto 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

EventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto)16 Test (org.junit.jupiter.api.Test)9 DataObject (org.openmuc.jdlms.datatypes.DataObject)8 DateTime (org.joda.time.DateTime)7 ArrayList (java.util.ArrayList)5 EventMessageDataResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)5 EventDetailDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDetailDto)4 AttributeAddress (org.openmuc.jdlms.AttributeAddress)3 FindEventsRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto)3 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)2 ProtocolInfo (org.opensmartgridplatform.domain.core.entities.ProtocolInfo)2 EventDetail (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventDetail)2 EventMessagesResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventMessagesResponse)2 EventTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventTypeDto)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 MappingContext (ma.glasnost.orika.MappingContext)1 BidirectionalConverter (ma.glasnost.orika.converter.BidirectionalConverter)1 Type (ma.glasnost.orika.metadata.Type)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1