use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener in project open-smart-grid-platform by OSGP.
the class DlmsConnectionHelperTest method doesNotPingDeviceBeforeCreatingConnectionIfPingingIsDisabled.
@Test
void doesNotPingDeviceBeforeCreatingConnectionIfPingingIsDisabled() throws Exception {
final String deviceIpAddress = "192.168.92.56";
when(this.devicePingConfig.pingingEnabled()).thenReturn(false);
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true).build();
device.setIpAddress(deviceIpAddress);
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
this.helper.createAndHandleConnectionForDevice(this.messageMetadata, device, listener, this.task);
verifyNoInteractions(this.pinger);
verifyNoMoreInteractions(this.devicePingConfig);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener in project open-smart-grid-platform by OSGP.
the class DlmsConnectionHelperTest method noInteractionsWithInvocationCounterManagerForDeviceThatDoesNotNeedInvocationCounter.
@Test
void noInteractionsWithInvocationCounterManagerForDeviceThatDoesNotNeedInvocationCounter() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(false).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);
verifyNoInteractions(this.invocationCounterManager);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener in project open-smart-grid-platform by OSGP.
the class DlmsConnectionHelperTest method invocationCounterUpdateSuccesfull.
@Test
void invocationCounterUpdateSuccesfull() 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.");
// First try throw exception, second time no exception
doThrow(exception).doNothing().when(this.connectionFactory).createAndHandleConnection(this.messageMetadata, device, listener, null, this.task);
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 initializesInvocationCounterForDeviceThatNeedsInvocationCounterWithInvocationCounterUninitialized.
@Test
void initializesInvocationCounterForDeviceThatNeedsInvocationCounterWithInvocationCounterUninitialized() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true).withProtocol("SMR").withInvocationCounter(null).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);
verify(this.invocationCounterManager).initializeInvocationCounter(this.messageMetadata, device);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.infra.messaging.DlmsMessageListener in project open-smart-grid-platform by OSGP.
the class DlmsConnectionFactoryTest method createsConnectionManagerForHls5Device.
@Test
void createsConnectionManagerForHls5Device() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
when(this.hls5Connector.connect(this.messageMetadata, device, listener)).thenReturn(this.connection);
final DlmsConnectionManager expected = this.newConnectionManager(device, listener, this.hls5Connector);
this.factory.createAndHandleConnection(this.messageMetadata, device, listener, this.task);
this.assertConnectionManagerForDevice(expected);
}
Aggregations