Search in sources :

Example 21 with DlmsDevice

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileCommandExecutorTest method executeWithoutSelectiveAccess.

@Test
public void executeWithoutSelectiveAccess() throws ProtocolAdapterException {
    final DlmsDevice dlmsDevice = new DlmsDevice();
    dlmsDevice.setSelectiveAccessSupported(false);
    this.executor.execute(this.conn, dlmsDevice, this.getPowerQualityProfileRequestDataDto, messageMetadata);
    verify(this.getPowerQualityProfileNoSelectiveAccessHandler).handle(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(GetPowerQualityProfileRequestDataDto.class));
}
Also used : GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) Test(org.junit.jupiter.api.Test)

Example 22 with DlmsDevice

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileCommandExecutorTest method executeWithSelectiveAccess.

@Test
public void executeWithSelectiveAccess() throws ProtocolAdapterException {
    final DlmsDevice dlmsDevice = new DlmsDevice();
    dlmsDevice.setSelectiveAccessSupported(true);
    this.executor.execute(this.conn, dlmsDevice, this.getPowerQualityProfileRequestDataDto, messageMetadata);
    verify(this.getPowerQualityProfileSelectiveAccessHandler).handle(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(GetPowerQualityProfileRequestDataDto.class));
}
Also used : GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) Test(org.junit.jupiter.api.Test)

Example 23 with DlmsDevice

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.

the class DlmsHelperTest method testGetWithListWorkaround.

@Test
public void testGetWithListWorkaround() throws ProtocolAdapterException, IOException {
    final DlmsConnection dlmsConnection = mock(DlmsConnection.class);
    final DlmsConnectionManager connectionManager = mock(DlmsConnectionManager.class);
    final DlmsDevice dlmsDevice = mock(DlmsDevice.class);
    when(connectionManager.getConnection()).thenReturn(dlmsConnection);
    final AttributeAddress[] attrAddresses = new AttributeAddress[1];
    attrAddresses[0] = mock(AttributeAddress.class);
    when(dlmsDevice.isWithListSupported()).thenReturn(false);
    this.dlmsHelper.getWithList(connectionManager, dlmsDevice, attrAddresses);
    verify(dlmsConnection).get(attrAddresses[0]);
}
Also used : AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsConnection(org.openmuc.jdlms.DlmsConnection) Test(org.junit.jupiter.api.Test)

Example 24 with DlmsDevice

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.

the class DeviceConverter method convertTo.

@Override
public DlmsDevice convertTo(final SmartMeteringDeviceDto source, final Type<DlmsDevice> destinationType, final MappingContext context) {
    final DlmsDevice dlmsDevice = new DlmsDevice();
    dlmsDevice.setDeviceIdentification(source.getDeviceIdentification());
    dlmsDevice.setCommunicationMethod(source.getCommunicationMethod());
    dlmsDevice.setCommunicationProvider(source.getCommunicationProvider());
    dlmsDevice.setIccId(source.getIccId());
    dlmsDevice.setHls3Active(source.isHls3Active());
    dlmsDevice.setHls4Active(source.isHls4Active());
    dlmsDevice.setHls5Active(source.isHls5Active());
    dlmsDevice.setMbusIdentificationNumber(source.getMbusIdentificationNumber());
    dlmsDevice.setMbusManufacturerIdentification(source.getMbusManufacturerIdentification());
    dlmsDevice.setProtocol(source.getProtocolName(), source.getProtocolVersion());
    return dlmsDevice;
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)

Example 25 with DlmsDevice

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.

the class DeviceKeyProcessingServiceTest method testNoKeyProcessRunning.

@Test
public void testNoKeyProcessRunning() {
    final DlmsDevice dlmsDevice = new DlmsDevice();
    dlmsDevice.setDeviceIdentification(DEVICE_IDENTIFICATION);
    when(this.dlmsDeviceRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(dlmsDevice);
    when(this.dlmsDeviceRepository.setProcessingStartTime(eq(DEVICE_IDENTIFICATION), any(Instant.class))).thenReturn(1);
    assertDoesNotThrow(() -> this.deviceKeyProcessingService.startProcessing(DEVICE_IDENTIFICATION));
}
Also used : Instant(java.time.Instant) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Test(org.junit.jupiter.api.Test)

Aggregations

DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)103 Test (org.junit.jupiter.api.Test)58 DlmsDeviceBuilder (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder)24 DlmsMessageListener (org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener)17 InvocationCountingDlmsMessageListener (org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.InvocationCountingDlmsMessageListener)17 AttributeAddress (org.openmuc.jdlms.AttributeAddress)15 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)13 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)10 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)10 Then (io.cucumber.java.en.Then)9 DataObject (org.openmuc.jdlms.datatypes.DataObject)7 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)7 AccessResultCode (org.openmuc.jdlms.AccessResultCode)6 Instant (java.time.Instant)5 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)5 IOException (java.io.IOException)4 Date (java.util.Date)4 List (java.util.List)4 ThrowableAssert.catchThrowable (org.assertj.core.api.ThrowableAssert.catchThrowable)4 SetParameter (org.openmuc.jdlms.SetParameter)4