Search in sources :

Example 1 with DataObjectToEventListConverter

use of org.opensmartgridplatform.adapter.protocol.dlms.application.mapping.DataObjectToEventListConverter in project open-smart-grid-platform by OSGP.

the class FindEventsCommandExecutorTest method before.

@BeforeEach
public void before() throws ProtocolAdapterException, IOException {
    final DataObject fromDate = mock(DataObject.class);
    final DataObject toDate = mock(DataObject.class);
    this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
    this.findEventsRequestDto = new FindEventsRequestDto(EventLogCategoryDto.POWER_QUALITY_EVENT_LOG, DateTime.now().minusDays(70), DateTime.now());
    final DataObjectToEventListConverter dataObjectToEventListConverter = new DataObjectToEventListConverter(this.dlmsHelper);
    final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(this.dlmsHelper, new DlmsObjectConfigConfiguration().getDlmsObjectConfigs());
    this.executor = new FindEventsCommandExecutor(this.dlmsHelper, dataObjectToEventListConverter, dlmsObjectConfigService);
    when(this.dlmsHelper.asDataObject(this.findEventsRequestDto.getFrom())).thenReturn(fromDate);
    when(this.dlmsHelper.asDataObject(this.findEventsRequestDto.getUntil())).thenReturn(toDate);
    when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenReturn(new CosemDateTimeDto());
    when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
    when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
    when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(this.getResult);
}
Also used : DlmsObjectConfigConfiguration(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration) FindEventsRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) DataObject(org.openmuc.jdlms.datatypes.DataObject) DataObjectToEventListConverter(org.opensmartgridplatform.adapter.protocol.dlms.application.mapping.DataObjectToEventListConverter) AttributeAddress(org.openmuc.jdlms.AttributeAddress) CosemDateTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BeforeEach (org.junit.jupiter.api.BeforeEach)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)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 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)1 FindEventsRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto)1