DlmsObjectConfigService { public Optional<AttributeAddress> findAttributeAddress(final DlmsDevice device, final DlmsObjectType type, final Integer channel) { return this.findAttributeAddressForProfile(device, type, channel, null, null, null) .map(AttributeAddressForProfile::getAttributeAddress); } @Autowired  DlmsObjectConfigService(final DlmsHelper dlmsHelper, final List<DlmsObjectConfig> dlmsObjectConfigs); Optional<AttributeAddress> findAttributeAddress(final DlmsDevice device, final DlmsObjectType type,
                                                           final Integer channel); Optional<AttributeAddressForProfile> findAttributeAddressForProfile(final DlmsDevice device,
                                                                               final DlmsObjectType type, final Integer channel, final DateTime from, final DateTime to,
                                                                               final Medium filterMedium); Optional<DlmsObject> findDlmsObject(final Protocol protocol, final DlmsObjectType type,
                                               final Medium filterMedium); List<AttributeAddress> getAttributeAddressesForScalerUnit(final AttributeAddressForProfile attributeAddressForProfile,
                                                                     final Integer channel);  }
@Test public void testNoMatchingObject() throws Exception { final Optional<AttributeAddress> attributeAddress = this.service.findAttributeAddress(this.device51, DlmsObjectType.AMR_STATUS, null); assertThat(attributeAddress.isPresent()).isFalse(); }
@Test public void testNoMatchingObjectForProtocol() throws Exception { final Optional<AttributeAddress> attributeAddress = this.service.findAttributeAddress(this.device51, DlmsObjectType.INTERVAL_VALUES, null); assertThat(attributeAddress.isPresent()).isFalse(); }
@Test public void testOneMatchingObject() throws Exception { final AttributeAddress expectedAddress = new AttributeAddress(this.register.getClassId(), this.register.getObisCodeAsString(), this.register.getDefaultAttributeId(), null); final Optional<AttributeAddress> attributeAddress = this.service.findAttributeAddress(this.device422, DlmsObjectType.ACTIVE_ENERGY_IMPORT, null); AttributeAddressAssert.is(attributeAddress.get(), expectedAddress); }
@Test public void testOneMatchingObjectWithChannel() throws Exception { final Integer channel = 1; final AttributeAddress expectedAddress = new AttributeAddress(this.registerWithChannel.getClassId(), this.getObisCodeWithChannel(this.registerWithChannel.getObisCodeAsString(), channel), this.registerWithChannel.getDefaultAttributeId(), null); final Optional<AttributeAddress> attributeAddress = this.service.findAttributeAddress(this.device422, DlmsObjectType.MBUS_MASTER_VALUE, channel); AttributeAddressAssert.is(attributeAddress.get(), expectedAddress); }