GetConfigurationObjectService implements ProtocolService { public ConfigurationObjectDto getConfigurationObject(final DlmsConnectionManager conn) throws ProtocolAdapterException { final AttributeAddress attributeAddress = AttributeAddressFactory.getConfigurationObjectAddress(); conn.getDlmsMessageListener().setDescription( String.format("Retrieve current ConfigurationObject, attribute: %s", JdlmsObjectToStringUtil.describeAttributes(attributeAddress))); return this.getConfigurationObject(this.getGetResult(conn, attributeAddress)); }  ConfigurationObjectDto getConfigurationObject(final DlmsConnectionManager conn);  }
@Test public void getConfigurationObjectIOException() throws Exception { when(this.dlmsConnection.get(any(AttributeAddress.class))).thenThrow(new IOException()); assertThatExceptionOfType(ConnectionException.class).isThrownBy(() -> { this.instance.getConfigurationObject(this.conn); }); }
@Test public void getConfigurationObjectGetResultNull() throws Exception { when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(null); assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> { this.instance.getConfigurationObject(this.conn); }); }
@Test public void getConfigurationObjectGetResultUnsuccessful() throws Exception { when(this.getResult.getResultCode()).thenReturn(AccessResultCode.READ_WRITE_DENIED); when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(this.getResult); assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> { this.instance.getConfigurationObject(this.conn); }); }