use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps in project netconf by opendaylight.
the class FieldsAwareReadOnlyTxTest method testReadWithFields.
@Test
public void testReadWithFields() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(mockedNode))).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
try (FieldsAwareReadOnlyTx readOnlyTx = new FieldsAwareReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)))) {
readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty(), List.of(YangInstanceIdentifier.empty()));
verify(rpc).invokeRpc(eq(NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
verify(rpc).invokeRpc(eq(NETCONF_GET_QNAME), any(ContainerNode.class));
}
}
use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testListenerFailure.
@Test
public void testListenerFailure() throws Exception {
final IllegalStateException cause = new IllegalStateException("Failed tx");
doReturn(FluentFutures.immediateFailedFluentFuture(cause)).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchema().getMountPointContext()), false);
final TxListener listener = mock(TxListener.class);
tx.addListener(listener);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
tx.commit();
final ArgumentCaptor<Exception> excCaptor = ArgumentCaptor.forClass(Exception.class);
verify(listener).onTransactionSubmitted(tx);
verify(listener).onTransactionFailed(eq(tx), excCaptor.capture());
Assert.assertEquals(cause, excCaptor.getValue().getCause().getCause());
verify(listener, never()).onTransactionSuccessful(tx);
verify(listener, never()).onTransactionCancelled(tx);
}
use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testIgnoreNonVisibleData.
@Test
public void testIgnoreNonVisibleData() {
final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(MountPointContext.class)), false);
final MapNode emptyList = ImmutableNodes.mapNodeBuilder(NETCONF_FILTER_QNAME).build();
tx.merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(NETCONF_FILTER_QNAME)), emptyList);
tx.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(NETCONF_FILTER_QNAME)), emptyList);
verify(rpc, atMost(1)).invokeRpc(any(QName.class), any(ContainerNode.class));
}
use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testListenerSuccess.
@Test
public void testListenerSuccess() throws Exception {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchema().getMountPointContext()), false);
final TxListener listener = mock(TxListener.class);
tx.addListener(listener);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
tx.commit();
verify(listener).onTransactionSubmitted(tx);
verify(listener).onTransactionSuccessful(tx);
verify(listener, never()).onTransactionFailed(eq(tx), any());
verify(listener, never()).onTransactionCancelled(tx);
}
use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testListenerCancellation.
@Test
public void testListenerCancellation() throws Exception {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))).when(rpc).invokeRpc(any(QName.class), isNull());
final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchema().getMountPointContext()), false);
final TxListener listener = mock(TxListener.class);
tx.addListener(listener);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
tx.cancel();
verify(listener).onTransactionCancelled(tx);
verify(listener, never()).onTransactionSubmitted(tx);
verify(listener, never()).onTransactionSuccessful(tx);
verify(listener, never()).onTransactionFailed(eq(tx), any());
}
Aggregations