SimpleIrdEntryListener implements AutoCloseable, DataTreeChangeListener<IrdConfigurationEntry> { protected void update(IrdInstanceConfiguration cfg, ReadWriteTransaction rwx) { List<IrdConfigurationEntry> filtered = new LinkedList<>(cfg.getIrdConfigurationEntry()); Map<IrdConfigurationEntry, Resource> resources; resources = readEntries(filtered, rwx); try { if (resources == null) { cleanupIrdInstance(cfg, rwx); } else { Map<ResourceId, List<ResourceId>> dependencyMap = resolveDependency(resources); updateIrdInstance(cfg, resources, dependencyMap, rwx); } } catch (Exception e) { cleanupIrdInstance(cfg, rwx); } } SimpleIrdEntryListener(InstanceIdentifier<Resource> instance, Uuid entryContext); void register(DataBroker dataBroker, InstanceIdentifier<IrdConfigurationEntry> iid); @Override synchronized void onDataTreeChanged(Collection<DataTreeModification<IrdConfigurationEntry>> changes); @Override synchronized void close();  }
@Test public void update() throws Exception { List<IrdConfigurationEntry> entryList = new LinkedList<>(); entryList.add(new IrdConfigurationEntryBuilder().build()); List<IrdConfigurationEntry> configs = new LinkedList<>(); ContextKey ck = new ContextKey(new Uuid(DEFAULT_CONTEXT_UUID)); ResourceKey rk = new ResourceKey(new ResourceId("FIRST_RESOURCE")); ResourceKey ik = new ResourceKey(new ResourceId("FIRST_INSTANCE")); InstanceIdentifier<Resource> resourceIID = InstanceIdentifier.builder(Context.class, ck) .child(Resource.class, rk).build(); InstanceIdentifier<Resource> instanceIID = InstanceIdentifier.builder(Context.class, ck) .child(Resource.class, ik).build(); IrdConfigurationEntryBuilder configBuilder = new IrdConfigurationEntryBuilder() .setEntryId(new ResourceId("THE_FIRST_ENTRY_ID")) .setInstance(instanceIID) .setLocation(new FixedUrlBuilder() .setUri(new Uri("http: configs.add(configBuilder.build()); IrdInstanceConfigurationBuilder iicb = new IrdInstanceConfigurationBuilder() .setIrdConfigurationEntry(configs); simpleIrdEntryListener.update(iicb.build(), rwx); }