use of org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices in project mdsal by opendaylight.
the class BindingDOMRpcImplementationAdapterTest method basicTest.
@Test
public void basicTest() throws Exception {
final BindingDOMCodecServices registry = mock(BindingDOMCodecServices.class);
final Method testMethod = this.getClass().getDeclaredMethod("testMethod");
final QName rpcType = QName.create(QNameModule.create(XMLNamespace.of("tst")), "test");
final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(new ConstantAdapterContext(registry), OpendaylightTestRpcServiceService.class, ImmutableMap.of(rpcType, testMethod), mock(OpendaylightTestRpcServiceService.class));
assertNotNull(adapter);
}
use of org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices in project mdsal by opendaylight.
the class LazyDataTreeModificationTest method basicTest.
@Test
public void basicTest() throws Exception {
final BindingDOMCodecServices registry = mock(BindingDOMCodecServices.class);
final AdapterContext codec = new ConstantAdapterContext(registry);
final DOMDataTreeCandidate domDataTreeCandidate = mock(DOMDataTreeCandidate.class);
final DOMDataTreeIdentifier domDataTreeIdentifier = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
doReturn(InstanceIdentifier.create(BooleanContainer.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));
}
use of org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices in project mdsal by opendaylight.
the class BindingDOMMountPointServiceAdapterTest method basicTest.
@Test
public void basicTest() throws Exception {
final BindingDOMCodecServices registry = mock(BindingDOMCodecServices.class);
final AdapterContext codec = new ConstantAdapterContext(registry);
doReturn(YangInstanceIdentifier.empty()).when(registry).toYangInstanceIdentifier(any());
final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
final BindingDOMMountPointServiceAdapter adapter = new BindingDOMMountPointServiceAdapter(codec, mountPointService);
doReturn(Optional.empty()).when(mountPointService).getMountPoint(any());
assertFalse(adapter.getMountPoint(InstanceIdentifier.create(BooleanContainer.class)).isPresent());
doReturn(Optional.of(mock(DOMMountPoint.class))).when(mountPointService).getMountPoint(any());
assertTrue(adapter.getMountPoint(InstanceIdentifier.create(BooleanContainer.class)).isPresent());
assertNotNull(adapter.registerListener(InstanceIdentifier.create(BooleanContainer.class), mock(MountPointListener.class)));
}
use of org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices in project mdsal by opendaylight.
the class BindingDOMDataTreeCommitCohortAdapterTest method canCommitTest.
@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(BooleanContainer.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, List.of(domDataTreeCandidate, domDataTreeCandidate));
ArgumentCaptor<Collection> modifications = ArgumentCaptor.forClass(Collection.class);
verify(cohort).canCommit(eq(txId), modifications.capture());
assertEquals(2, modifications.getValue().size());
}
Aggregations