Search in sources :

Example 1 with BindingDOMCodecServices

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);
}
Also used : OpendaylightTestRpcServiceService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService) QName(org.opendaylight.yangtools.yang.common.QName) BindingDOMCodecServices(org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with BindingDOMCodecServices

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));
}
Also used : DOMDataTreeCandidate(org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) BooleanContainer(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) BindingDOMCodecServices(org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 3 with BindingDOMCodecServices

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)));
}
Also used : BooleanContainer(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer) BindingDOMCodecServices(org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) Test(org.junit.Test)

Example 4 with BindingDOMCodecServices

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());
}
Also used : DOMDataTreeCandidate(org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) BooleanContainer(org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) BindingDOMCodecServices(org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 BindingDOMCodecServices (org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices)4 BooleanContainer (org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer)3 DOMDataTreeCandidate (org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate)2 DOMDataTreeIdentifier (org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode)2 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 DOMMountPointService (org.opendaylight.mdsal.dom.api.DOMMountPointService)1 OpendaylightTestRpcServiceService (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService)1 QName (org.opendaylight.yangtools.yang.common.QName)1