GetConfigurationObjectServiceSmr5 extends GetConfigurationObjectService { @Override ConfigurationObjectDto getConfigurationObject(final GetResult result) throws ProtocolAdapterException { final DataObject resultData = result.getResultData(); if (resultData == null || !resultData.isBitString()) { LOGGER.warn("Configuration object result data is not a BitString: {}", resultData); throw new ProtocolAdapterException( "Expected bit-string data as Configuration object result data, but got: " + ( resultData == null ? "null" : resultData.getType())); } LOGGER.info("SMR5 Configuration object current BitString: {}", this.dlmsHelper.getDebugInfo(resultData)); final BitString bitString = resultData.getValue(); final byte[] flagByteArray = bitString.getBitString(); final List<ConfigurationFlagDto> configurationFlagDtos = this.toConfigurationFlags(flagByteArray); final ConfigurationFlagsDto configurationFlagsDto = new ConfigurationFlagsDto(configurationFlagDtos); return new ConfigurationObjectDto(configurationFlagsDto); } GetConfigurationObjectServiceSmr5(final DlmsHelper dlmsHelper); @Override boolean handles(final Protocol protocol);  }
@Test public void getConfigurationObjectResultDataNull() throws ProtocolAdapterException { when(this.getResult.getResultData()).thenReturn(null); assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> { this.instance.getConfigurationObject(this.getResult); }); }
@Test public void getConfigurationObjectResultDataNotBitString() throws ProtocolAdapterException { when(this.getResult.getResultData()).thenReturn(this.nonBitString); assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> { this.instance.getConfigurationObject(this.getResult); }); }