BindingDOMDataTreeCommitCohortAdapter extends AbstractBindingAdapter<DataTreeCommitCohort<T>> implements DOMDataTreeCommitCohort { @Override public FluentFuture<PostCanCommitStep> canCommit(final Object txId, final SchemaContext ctx, final Collection<DOMDataTreeCandidate> candidates) { final Collection<DataTreeModification<T>> modifications = candidates.stream() .map(candidate -> LazyDataTreeModification.<T>create(currentSerializer(), candidate)) .collect(Collectors.toList()); return getDelegate().canCommit(txId, modifications); } BindingDOMDataTreeCommitCohortAdapter(final AdapterContext codec, final DataTreeCommitCohort<T> cohort); @Override FluentFuture<PostCanCommitStep> canCommit(final Object txId,
            final SchemaContext ctx, final Collection<DOMDataTreeCandidate> candidates);  }
@Test public void canCommitTest() { final DataTreeCommitCohort<?> cohort = mock(DataTreeCommitCohort.class); final BindingDOMCodecServices registry = mock(BindingDOMCodecServices.class); final AdapterContext codec = new ConstantAdapterContext(registry); final BindingDOMDataTreeCommitCohortAdapter<?> adapter = new BindingDOMDataTreeCommitCohortAdapter<>(codec, cohort); assertNotNull(adapter); final DOMDataTreeCandidate domDataTreeCandidate = mock(DOMDataTreeCandidate.class); final DOMDataTreeIdentifier domDataTreeIdentifier = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty()); doReturn(InstanceIdentifier.create(DataObject.class)).when(registry).fromYangInstanceIdentifier(any()); final BindingDataObjectCodecTreeNode<?> bindingCodecTreeNode = mock(BindingDataObjectCodecTreeNode.class); doReturn(bindingCodecTreeNode).when(registry).getSubtreeCodec(any(InstanceIdentifier.class)); doReturn(domDataTreeIdentifier).when(domDataTreeCandidate).getRootPath(); doReturn(mock(DataTreeCandidateNode.class)).when(domDataTreeCandidate).getRootNode(); assertNotNull(LazyDataTreeModification.create(codec.currentSerializer(), domDataTreeCandidate)); final Object txId = new Object(); doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(), any()); adapter.canCommit(txId, null, Arrays.asList(domDataTreeCandidate, domDataTreeCandidate)); ArgumentCaptor<Collection> modifications = ArgumentCaptor.forClass(Collection.class); verify(cohort).canCommit(eq(txId), modifications.capture()); assertEquals(2, modifications.getValue().size()); }