use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener 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);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener 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));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener in project open-smart-grid-platform by OSGP.
the class DlmsConnectionHelperTest method initializesInvocationCounterWhenInvocationCounterIsOutOfSyncForIskraDevice.
@Test
void initializesInvocationCounterWhenInvocationCounterIsOutOfSyncForIskraDevice() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true).withProtocol("SMR").withInvocationCounter(123L).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
final ConnectionException exception = new ConnectionException("Error creating connection for device E0033006878667817 with Ip address:62.133.86.119 Port:4059 " + "UseHdlc:false UseSn:false Message:UNKNOWN: Received an association response (AARE) with an" + " error message. Result name REJECTED_PERMANENT. Assumed fault: user.");
doThrow(exception).when(this.connectionFactory).createAndHandleConnection(this.messageMetadata, device, listener, null, this.task);
assertThrows(ConnectionException.class, () -> this.helper.createAndHandleConnectionForDevice(this.messageMetadata, device, listener, null, this.task));
verify(this.invocationCounterManager).initializeInvocationCounter(this.messageMetadata, device);
verify(this.connectionFactory, times(2)).createAndHandleConnection(this.messageMetadata, device, listener, null, this.task);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener in project open-smart-grid-platform by OSGP.
the class DlmsConnectionHelperTest method createsConnectionForDeviceThatNeedsInvocationCounterWithInvocationCounterInitialized.
@Test
void createsConnectionForDeviceThatNeedsInvocationCounterWithInvocationCounterInitialized() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true).withInvocationCounter(123L).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
doNothing().when(this.connectionFactory).createAndHandleConnection(this.messageMetadata, device, listener, null, this.task);
this.helper.createAndHandleConnectionForDevice(this.messageMetadata, device, listener, this.task);
verifyNoMoreInteractions(this.invocationCounterManager);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener in project open-smart-grid-platform by OSGP.
the class DlmsConnectionHelperTest method initializesInvocationCounterWhenInvocationCounterIsOutOfSyncForLAndGDevice.
@Test
void initializesInvocationCounterWhenInvocationCounterIsOutOfSyncForLAndGDevice() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true).withProtocol("SMR").withInvocationCounter(123L).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
final ConnectionException exception = new ConnectionException("Error creating connection for device E0051004228715518 with Ip address:62.133.88.34 Port:null " + "UseHdlc:false UseSn:false Message:Socket was closed by remote host.");
doThrow(exception).when(this.connectionFactory).createAndHandleConnection(this.messageMetadata, device, listener, null, this.task);
assertThrows(ConnectionException.class, () -> this.helper.createAndHandleConnectionForDevice(this.messageMetadata, device, listener, null, this.task));
verify(this.invocationCounterManager).initializeInvocationCounter(this.messageMetadata, device);
verify(this.connectionFactory, times(2)).createAndHandleConnection(this.messageMetadata, device, listener, null, this.task);
}
Aggregations