use of org.openmuc.jdlms.DlmsConnection 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());
}
Aggregations