- public void testDiscardCahngesNotSentWithoutCandidate() {
- doReturn(Futures.immediateFuture(RpcResultBuilder.<CompositeNode>success().build()))
- .doReturn(Futures.<RpcResult<CompositeNode>>immediateFailedFuture(new IllegalStateException("Failed tx")))
- .when(rpc).invokeRpc(any(QName.class), any(CompositeNode.class));
-
- final NetconfDeviceWriteOnlyTx tx = new NetconfDeviceWriteOnlyTx(id, rpc, normalizer, false, true);
- tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
- verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), any(CompositeNode.class));
- verifyNoMoreInteractions(rpc);
+ public void testDiscardChangesNotSentWithoutCandidate() {
+ doReturn(Futures.immediateCheckedFuture(new DefaultDOMRpcResult(((NormalizedNode<?, ?>) null))))
+ .doReturn(Futures.immediateFailedCheckedFuture(new IllegalStateException("Failed tx")))
+ .when(rpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+
+ final WriteRunningTx tx = new WriteRunningTx(id, new NetconfBaseOps(rpc, NetconfDevice.INIT_SCHEMA_CTX),
+ false, 60000L);
+ try {
+ tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
+ } catch (final Exception e) {
+ // verify discard changes was sent
+ final InOrder inOrder = inOrder(rpc);
+ inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME), NetconfBaseOps.getLockContent(NETCONF_RUNNING_QNAME));
+ inOrder.verify(rpc).invokeRpc(eq(toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), any(NormalizedNode.class));
+ inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME), NetconfBaseOps.getUnLockContent(NETCONF_RUNNING_QNAME));
+ return;
+ }
+
+ fail("Delete should fail");