Search in sources :

Example 1 with DlmsObjectConfigConfiguration

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration in project open-smart-grid-platform by OSGP.

the class GetPeriodicMeterReadsCommandExecutorIntegrationTest method setUp.

@BeforeEach
public void setUp() {
    final TimeZone defaultTimeZone = TimeZone.getDefault();
    final DateTimeZone defaultDateTimeZone = DateTimeZone.getDefault();
    // all time based tests must use UTC time.
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    DateTimeZone.setDefault(DateTimeZone.UTC);
    this.initDates();
    this.dlmsHelper = new DlmsHelper();
    this.amrProfileStatusCodeHelper = new AmrProfileStatusCodeHelper();
    final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
    this.dlmsObjectConfigService = new DlmsObjectConfigService(this.dlmsHelper, dlmsObjectConfigConfiguration.getDlmsObjectConfigs());
    this.executor = new GetPeriodicMeterReadsCommandExecutor(this.dlmsHelper, this.amrProfileStatusCodeHelper, this.dlmsObjectConfigService);
    this.connectionStub = new DlmsConnectionStub();
    this.connectionManagerStub = new DlmsConnectionManagerStub(this.connectionStub);
    this.connectionStub.setDefaultReturnValue(DataObject.newArrayData(Collections.emptyList()));
    // reset to original TimeZone
    TimeZone.setDefault(defaultTimeZone);
    DateTimeZone.setDefault(defaultDateTimeZone);
}
Also used : DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DlmsObjectConfigConfiguration(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration) DateTimeZone(org.joda.time.DateTimeZone) TimeZone(java.util.TimeZone) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) DlmsConnectionManagerStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub) AmrProfileStatusCodeHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.AmrProfileStatusCodeHelper) DlmsConnectionStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionStub) DateTimeZone(org.joda.time.DateTimeZone) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with DlmsObjectConfigConfiguration

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration 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)

Example 3 with DlmsObjectConfigConfiguration

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration in project open-smart-grid-platform by OSGP.

the class GetGsmDiagnosticCommandExecutorIntegrationTest method setUp.

@BeforeEach
public void setUp() {
    final DlmsHelper dlmsHelper = new DlmsHelper();
    final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
    final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(dlmsHelper, dlmsObjectConfigConfiguration.getDlmsObjectConfigs());
    this.executor = new GetGsmDiagnosticCommandExecutor(dlmsHelper, dlmsObjectConfigService);
    this.connectionStub = new DlmsConnectionStub();
    this.connectionManagerStub = new DlmsConnectionManagerStub(this.connectionStub);
    this.connectionStub.setDefaultReturnValue(DataObject.newArrayData(Collections.emptyList()));
}
Also used : DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DlmsObjectConfigConfiguration(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) DlmsConnectionManagerStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub) DlmsConnectionStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionStub) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DlmsObjectConfigConfiguration

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration in project open-smart-grid-platform by OSGP.

the class SetAlarmNotificationsCommandExecutorTest method setUp.

@BeforeEach
public void setUp() {
    this.setParametersReceived = new ArrayList<>();
    this.device = new DlmsDevice("SuperAwesomeHeroicRockstarDevice");
    this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
    final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
    final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(new DlmsHelper(), dlmsObjectConfigConfiguration.getDlmsObjectConfigs()) {

        @Override
        public Optional<AttributeAddress> findAttributeAddress(final DlmsDevice device, final DlmsObjectType type, final Integer channel) {
            switch(type) {
                case ALARM_FILTER_1:
                    return Optional.of(new AttributeAddress(40, "0.0.97.98.10.255", 2));
                case ALARM_FILTER_2:
                    return Optional.of(new AttributeAddress(40, "0.0.97.98.11.255", 2));
            }
            return Optional.empty();
        }
    };
    this.executor = new SetAlarmNotificationsCommandExecutor(dlmsObjectConfigService);
    final DlmsConnectionStub conn = new DlmsConnectionStub() {

        @Override
        public AccessResultCode set(final SetParameter setParameter) {
            SetAlarmNotificationsCommandExecutorTest.this.setParametersReceived.add(setParameter);
            return AccessResultCode.SUCCESS;
        }
    };
    // Set the return value to 10 (0b1010):
    // REPLACE_BATTERY enabled, AUXILIARY_EVENT enabled.
    conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.10.255", 2), DataObject.newInteger32Data(10));
    conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.11.255", 2), DataObject.newInteger32Data(0));
    this.connMgr = new DlmsConnectionManagerStub(conn);
}
Also used : DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DlmsObjectConfigConfiguration(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) DlmsConnectionManagerStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsConnectionStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionStub) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) SetParameter(org.openmuc.jdlms.SetParameter) DlmsObjectType(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with DlmsObjectConfigConfiguration

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration in project open-smart-grid-platform by OSGP.

the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method setUp.

@BeforeEach
public void setUp() {
    final TimeZone defaultTimeZone = TimeZone.getDefault();
    final DateTimeZone defaultDateTimeZone = DateTimeZone.getDefault();
    // all time based tests must use UTC time.
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    DateTimeZone.setDefault(DateTimeZone.UTC);
    this.initDates();
    this.dlmsHelper = new DlmsHelper();
    this.amrProfileStatusCodeHelper = new AmrProfileStatusCodeHelper();
    final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
    this.dlmsObjectConfigService = new DlmsObjectConfigService(this.dlmsHelper, dlmsObjectConfigConfiguration.getDlmsObjectConfigs());
    this.executor = new GetPeriodicMeterReadsGasCommandExecutor(this.dlmsHelper, this.amrProfileStatusCodeHelper, this.dlmsObjectConfigService);
    this.connectionStub = new DlmsConnectionStub();
    this.connectionManagerStub = new DlmsConnectionManagerStub(this.connectionStub);
    this.connectionStub.setDefaultReturnValue(DataObject.newArrayData(Collections.emptyList()));
    // reset to original TimeZone
    TimeZone.setDefault(defaultTimeZone);
    DateTimeZone.setDefault(defaultDateTimeZone);
}
Also used : DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DlmsObjectConfigConfiguration(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration) DateTimeZone(org.joda.time.DateTimeZone) TimeZone(java.util.TimeZone) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) DlmsConnectionManagerStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub) AmrProfileStatusCodeHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.AmrProfileStatusCodeHelper) DlmsConnectionStub(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionStub) DateTimeZone(org.joda.time.DateTimeZone) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BeforeEach (org.junit.jupiter.api.BeforeEach)6 DlmsObjectConfigConfiguration (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration)6 DlmsObjectConfigService (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService)6 DlmsConnectionManagerStub (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub)4 DlmsConnectionStub (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionStub)4 DlmsHelper (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper)4 TimeZone (java.util.TimeZone)2 DateTimeZone (org.joda.time.DateTimeZone)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 AmrProfileStatusCodeHelper (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.AmrProfileStatusCodeHelper)2 SetParameter (org.openmuc.jdlms.SetParameter)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 DataObjectToEventListConverter (org.opensmartgridplatform.adapter.protocol.dlms.application.mapping.DataObjectToEventListConverter)1 DlmsObjectType (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType)1 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)1 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)1 FindEventsRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto)1