use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsConnectionFactoryTest method setsIpAddressWhenConnectingToTheDevice.
@Test
void setsIpAddressWhenConnectingToTheDevice() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true).withIpAddress(null).withIpAddressStatic(false).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
when(this.hls5Connector.connect(this.messageMetadata, device, listener)).thenReturn(this.connection);
this.factory.createAndHandleConnection(this.messageMetadata, device, listener, this.task);
verify(this.domainHelperService).setIpAddressFromMessageMetadataOrSessionProvider(device, this.messageMetadata);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsConnectionFactoryTest method createAndHandleConnectionThrowsForHls4Device.
@Test
void createAndHandleConnectionThrowsForHls4Device() {
final DlmsDevice device = new DlmsDeviceBuilder().withHls4Active(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.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DlmsConnectionFactoryTest method createsConnectionManagerForLls1Device.
@Test
void createsConnectionManagerForLls1Device() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withLls1Active(true).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
when(this.lls1Connector.connect(this.messageMetadata, device, listener)).thenReturn(this.connection);
final DlmsConnectionManager expected = this.newConnectionManager(device, listener, this.lls1Connector);
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 DlmsHelperTest method assertGetWithListException.
private void assertGetWithListException(final Class<? extends Exception> jdlmsExceptionClazz, final Class<? extends Exception> exceptionClazz) throws IOException {
final DlmsConnection dlmsConnection = mock(DlmsConnection.class);
final DlmsConnectionManager connectionManager = mock(DlmsConnectionManager.class);
final DlmsDevice dlmsDevice = mock(DlmsDevice.class);
when(dlmsDevice.getDeviceIdentification()).thenReturn("666");
when(connectionManager.getConnection()).thenReturn(dlmsConnection);
final AttributeAddress[] attrAddresses = new AttributeAddress[1];
attrAddresses[0] = mock(AttributeAddress.class);
when(dlmsDevice.isWithListSupported()).thenReturn(true);
when(dlmsConnection.get(Arrays.asList(attrAddresses))).thenThrow(jdlmsExceptionClazz);
final Exception exception = assertThrows(exceptionClazz, () -> {
this.dlmsHelper.getWithList(connectionManager, dlmsDevice, attrAddresses);
});
assertThat(exception.getMessage()).contains(dlmsDevice.getDeviceIdentification());
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutorTest method createDevice.
private DlmsDevice createDevice(final Protocol protocol, final CommunicationMethod method) {
final DlmsDevice device = new DlmsDevice();
device.setProtocol(protocol);
device.setCommunicationMethod(method.name());
device.setDeviceIdentification("1234567890");
return device;
}
Aggregations