use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice 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.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsHelperTest method testGetWithListSupported.
@Test
public void testGetWithListSupported() 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(true);
this.dlmsHelper.getWithList(connectionManager, dlmsDevice, attrAddresses);
verify(dlmsConnection).get(Arrays.asList(attrAddresses));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice 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);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice 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.domain.entities.DlmsDevice 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));
}
Aggregations