Search in sources :

Example 16 with DlmsDevice

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

the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method createDlmsDevice.

private DlmsDevice createDlmsDevice(final Protocol protocol) {
    final DlmsDevice device = new DlmsDevice();
    device.setProtocol(protocol);
    device.setSelectiveAccessSupported(true);
    return device;
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)

Example 17 with DlmsDevice

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

the class DlmsObjectConfigServiceTest method testNoMatchingDlmsObjectForCommunicationMethod.

@Test
public void testNoMatchingDlmsObjectForCommunicationMethod() throws ProtocolAdapterException {
    // SETUP
    final DlmsDevice deviceGprs = new DlmsDevice();
    deviceGprs.setDeviceIdentification("5151515151");
    deviceGprs.setCommunicationMethod("GPRS");
    // CALL
    try {
        this.service.getDlmsObjectForCommunicationMethod(deviceGprs, DlmsObjectType.GSM_DIAGNOSTIC);
        fail("Expected ProtocolAdapterException");
    } catch (final ProtocolAdapterException e) {
        assertThat(e.getMessage()).contains("Did not find GSM_DIAGNOSTIC");
    }
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) Test(org.junit.jupiter.api.Test)

Example 18 with DlmsDevice

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

the class GetFirmwareVersionsCommandExecutorTest method returns4FirmwareVersionsForSmr51Device.

@Test
public void returns4FirmwareVersionsForSmr51Device() throws Exception {
    final DlmsDevice device = new DlmsDevice();
    device.setProtocol(Protocol.SMR_5_1);
    final GetResult getResult1 = new GetResultBuilder().build();
    final GetResult getResult2 = new GetResultBuilder().build();
    final GetResult getResult3 = new GetResultBuilder().build();
    final GetResult getResult4 = new GetResultBuilder().build();
    when(this.helperService.getAndCheck(same(this.connectionHolder), same(device), eq("retrieve firmware versions"), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_COMMUNICATION_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_MBUS_DRIVER_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)))).thenReturn(asList(getResult1, getResult2, getResult3, getResult4));
    when(this.helperService.readString(getResult1.getResultData(), FirmwareModuleType.ACTIVE_FIRMWARE.getDescription())).thenReturn("string1");
    when(this.helperService.readString(getResult2.getResultData(), FirmwareModuleType.MODULE_ACTIVE.getDescription())).thenReturn("string2");
    when(this.helperService.readString(getResult3.getResultData(), FirmwareModuleType.COMMUNICATION.getDescription())).thenReturn("string3");
    when(this.helperService.readString(getResult4.getResultData(), FirmwareModuleType.M_BUS_DRIVER_ACTIVE.getDescription())).thenReturn("string4");
    final List<FirmwareVersionDto> result = this.executor.execute(this.connectionHolder, device, null, this.messageMetadata);
    Assertions.assertThat(result).usingRecursiveFieldByFieldElementComparator().containsExactly(new FirmwareVersionDto(FirmwareModuleType.ACTIVE_FIRMWARE, "string1"), new FirmwareVersionDto(FirmwareModuleType.MODULE_ACTIVE, "string2"), new FirmwareVersionDto(FirmwareModuleType.COMMUNICATION, "string3"), new FirmwareVersionDto(FirmwareModuleType.M_BUS_DRIVER_ACTIVE, "string4"));
}
Also used : GetResult(org.openmuc.jdlms.GetResult) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) GetResultBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultBuilder) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto) Test(org.junit.jupiter.api.Test)

Example 19 with DlmsDevice

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

the class GetFirmwareVersionsCommandExecutorTest method returns3FirmwareVersionsForDsmr422Device.

@Test
public void returns3FirmwareVersionsForDsmr422Device() throws Exception {
    final DlmsDevice device = new DlmsDevice();
    final GetResult getResult1 = new GetResultBuilder().build();
    final GetResult getResult2 = new GetResultBuilder().build();
    final GetResult getResult3 = new GetResultBuilder().build();
    when(this.helperService.getAndCheck(same(this.connectionHolder), same(device), eq("retrieve firmware versions"), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)), refEq(new AttributeAddress(CLASS_ID, OBIS_CODE_COMMUNICATION_MODULE_ACTIVE_FIRMWARE_VERSION, ATTRIBUTE_ID)))).thenReturn(asList(getResult1, getResult2, getResult3));
    when(this.helperService.readString(getResult1.getResultData(), FirmwareModuleType.ACTIVE_FIRMWARE.getDescription())).thenReturn("string1");
    when(this.helperService.readString(getResult2.getResultData(), FirmwareModuleType.MODULE_ACTIVE.getDescription())).thenReturn("string2");
    when(this.helperService.readString(getResult3.getResultData(), FirmwareModuleType.COMMUNICATION.getDescription())).thenReturn("string3");
    final List<FirmwareVersionDto> result = this.executor.execute(this.connectionHolder, device, null, this.messageMetadata);
    Assertions.assertThat(result).usingRecursiveFieldByFieldElementComparator().containsExactly(new FirmwareVersionDto(FirmwareModuleType.ACTIVE_FIRMWARE, "string1"), new FirmwareVersionDto(FirmwareModuleType.MODULE_ACTIVE, "string2"), new FirmwareVersionDto(FirmwareModuleType.COMMUNICATION, "string3"));
}
Also used : GetResult(org.openmuc.jdlms.GetResult) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) GetResultBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultBuilder) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto) Test(org.junit.jupiter.api.Test)

Example 20 with DlmsDevice

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

the class GetGsmDiagnosticCommandExecutorIntegrationTest method createDlmsDevice.

private DlmsDevice createDlmsDevice(final Protocol protocol, final CommunicationMethod method) {
    final DlmsDevice device = new DlmsDevice();
    device.setDeviceIdentification("123456789012");
    device.setProtocol(protocol);
    device.setCommunicationMethod(method.getMethodName());
    return device;
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)

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