DeviceChannelsHelper { protected ChannelElementValuesDto makeChannelElementValues(final short channel, final List<GetResult> resultList) throws ProtocolAdapterException { final short primaryAddress = this.readShort(resultList, INDEX_PRIMARY_ADDRESS, "primaryAddress"); final String identificationNumber = this.readIdentificationNumber(resultList, INDEX_IDENTIFICATION_NUMBER, "identificationNumber"); final String manufacturerIdentification = this.readManufacturerIdentification(resultList, INDEX_MANUFACTURER_ID, "manufacturerIdentification"); final short version = this.readShort(resultList, INDEX_VERSION, "version"); final short deviceTypeIdentification = this.readShort(resultList, INDEX_DEVICE_TYPE, "deviceTypeIdentification"); return new ChannelElementValuesDto(channel, primaryAddress, identificationNumber, manufacturerIdentification, version, deviceTypeIdentification); } @Autowired  DeviceChannelsHelper(final DlmsHelper dlmsHelper); List<ChannelElementValuesDto> findCandidateChannelsForDevice(final DlmsConnectionManager conn,
            final DlmsDevice device, final MbusChannelElementsDto requestDto);  }
@Test public void testMakeChannelElementValues() throws Exception { final List<GetResult> resultList = new ArrayList<>(Arrays.asList(this.primaryAddress, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceType)); final ChannelElementValuesDto values = this.deviceChannelsHelper.makeChannelElementValues((short) 1, resultList); assertThat(values.getPrimaryAddress()).isEqualTo(PRIMARY_ADDRESS); assertThat(values.getIdentificationNumber()).isEqualTo(String.valueOf(IDENTIFICATION_NUMBER)); assertThat(values.getManufacturerIdentification()).isEqualTo(MANUFACTURER_IDENTIFICATION_AS_TEXT); assertThat(values.getVersion()).isEqualTo(VERSION); assertThat(values.getDeviceTypeIdentification()).isEqualTo(DEVICE_TYPE); }
@Test public void testMakeChannelElementValuesInvalidManufacturerId() throws Exception { final GetResult manufacturerIdentificationInvalid = new GetResultImpl(DataObject.newUInteger16Data(123)); final List<GetResult> resultList = new ArrayList<>(Arrays.asList(this.primaryAddress, this.identificationNumber, manufacturerIdentificationInvalid, this.version, this.deviceType)); assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> { this.deviceChannelsHelper.makeChannelElementValues((short) 1, resultList); }); }
@Test public void testMakeChannelElementValuesIdenfiticationNumberNull() throws Exception { final GetResult identificationNumberNull = new GetResultImpl(null); final List<GetResult> resultList = new ArrayList<>(Arrays.asList(this.primaryAddress, identificationNumberNull, this.manufacturerIdentification, this.version, this.deviceType)); final ChannelElementValuesDto values = this.deviceChannelsHelper.makeChannelElementValues((short) 1, resultList); assertThat(values.getIdentificationNumber()).isEqualTo(null); }