Search in sources :

Example 11 with DlmsDeviceBuilder

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

the class DlmsConnectionFactoryTest method createsConnectionManagerForLls0Device.

@Test
void createsConnectionManagerForLls0Device() throws Exception {
    final DlmsDevice device = new DlmsDeviceBuilder().withLls1Active(false).build();
    final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
    when(this.lls0Connector.connect(this.messageMetadata, device, listener)).thenReturn(this.connection);
    final DlmsConnectionManager expected = this.newConnectionManager(device, listener, this.lls0Connector);
    this.factory.createAndHandleConnection(this.messageMetadata, device, listener, this.task);
    this.assertConnectionManagerForDevice(expected);
}
Also used : DlmsMessageListener(org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener) InvocationCountingDlmsMessageListener(org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.InvocationCountingDlmsMessageListener) InvocationCountingDlmsMessageListener(org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.InvocationCountingDlmsMessageListener) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Test(org.junit.jupiter.api.Test)

Example 12 with DlmsDeviceBuilder

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

the class DlmsConnectionFactoryTest method createAndHandleConnectionThrowsForHls3Device.

@Test
void createAndHandleConnectionThrowsForHls3Device() {
    final DlmsDevice device = new DlmsDeviceBuilder().withHls3Active(true).build();
    final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
    assertThatExceptionOfType(FunctionalException.class).isThrownBy(() -> this.factory.createAndHandleConnection(this.messageMetadata, device, listener, this.task));
}
Also used : DlmsMessageListener(org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener) InvocationCountingDlmsMessageListener(org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.InvocationCountingDlmsMessageListener) InvocationCountingDlmsMessageListener(org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.InvocationCountingDlmsMessageListener) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Test(org.junit.jupiter.api.Test)

Example 13 with DlmsDeviceBuilder

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

the class DomainHelperServiceTest method setsIpAddressFromSessionProviderIfIpAddressIsNotStatic.

@Test
void setsIpAddressFromSessionProviderIfIpAddressIsNotStatic() throws Exception {
    final String communicationProvider = "comm-prov";
    final String iccId = "icc-id";
    final String ipAddress = IP_ADDRESS;
    this.whenSessionProviderReturnsIpAddressAfterWakeUp(communicationProvider, iccId, ipAddress);
    final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withIpAddressStatic(false).withCommunicationProvider(communicationProvider).setIccId(iccId).build();
    final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withIpAddress(null).build();
    this.domainHelperService.setIpAddressFromMessageMetadataOrSessionProvider(dlmsDevice, messageMetadata);
    assertThat(dlmsDevice.getIpAddress()).isEqualTo(ipAddress);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Test(org.junit.jupiter.api.Test)

Example 14 with DlmsDeviceBuilder

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

the class SystemEventServiceTest method verifyMaxValueNotReachedEvent.

@Test
void verifyMaxValueNotReachedEvent() {
    final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(this.invocationCounterEventThreshold - 1).build();
    final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
    this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
    verifyNoInteractions(this.correlationIdProviderService);
    verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Test(org.junit.jupiter.api.Test)

Example 15 with DlmsDeviceBuilder

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

the class SystemEventServiceTest method verifyInvocationCounterIsNull.

@Test
void verifyInvocationCounterIsNull() {
    final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(null).build();
    final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
    this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
    verifyNoInteractions(this.correlationIdProviderService);
    verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

DlmsDeviceBuilder (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder)28 Test (org.junit.jupiter.api.Test)25 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)24 DlmsMessageListener (org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener)18 InvocationCountingDlmsMessageListener (org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.InvocationCountingDlmsMessageListener)17 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)6 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Builder (org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder)3 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)3 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)2 Consumer (java.util.function.Consumer)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 SystemEventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto)1