BindingDOMDataTreeCommitCohortRegistryAdapter extends AbstractBindingAdapter<DOMDataTreeCommitCohortRegistry> implements DataTreeCommitCohortRegistry { @Override public <D extends DataObject, T extends DataTreeCommitCohort<D>> ObjectRegistration<T> registerCommitCohort( final DataTreeIdentifier<D> subtree, final T cohort) { final BindingDOMDataTreeCommitCohortAdapter<D> adapter = new BindingDOMDataTreeCommitCohortAdapter<>(adapterContext(), cohort); final DOMDataTreeIdentifier domPath = currentSerializer().toDOMDataTreeIdentifier(subtree); final DOMDataTreeCommitCohortRegistration<?> domReg = getDelegate().registerCommitCohort(domPath, adapter); return new ObjectRegistration<>() { @Override public T getInstance() { return cohort; } @Override public void close() { domReg.close(); } }; } BindingDOMDataTreeCommitCohortRegistryAdapter(final AdapterContext codec,
            final DOMDataTreeCommitCohortRegistry registry); @Override ObjectRegistration<T> registerCommitCohort(
            final DataTreeIdentifier<D> subtree, final T cohort);  }
@Test public void basicTest() throws Exception { final BindingBrokerTestFactory bindingBrokerTestFactory = new BindingBrokerTestFactory(); bindingBrokerTestFactory.setExecutor(MoreExecutors.newDirectExecutorService()); final BindingTestContext bindingTestContext = bindingBrokerTestFactory.getTestContext(); bindingTestContext.start(); final DOMDataTreeCommitCohortRegistry cohortRegistry = mock(DOMDataTreeCommitCohortRegistry.class); final DOMDataTreeCommitCohortRegistration<?> cohortRegistration = mock(DOMDataTreeCommitCohortRegistration.class); doReturn(cohortRegistration).when(cohortRegistry) .registerCommitCohort(any(), any()); doNothing().when(cohortRegistration).close(); final BindingDOMDataTreeCommitCohortRegistryAdapter registryAdapter = new BindingDOMDataTreeCommitCohortRegistryAdapter(bindingTestContext.getCodec(), cohortRegistry); final DataTreeIdentifier<Top> dataTreeIdentifier = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Top.class)); final DataTreeCommitCohort<Top> dataTreeCommitCohort = mock(DataTreeCommitCohort.class); final ObjectRegistration<?> objectRegistration = registryAdapter.registerCommitCohort(dataTreeIdentifier, dataTreeCommitCohort); assertEquals(dataTreeCommitCohort, objectRegistration.getInstance()); objectRegistration.close(); verify(cohortRegistration).close(); }