### Question:
ZKVersionedSetOp extends ZKOp { @Override protected void abortOpResult(Throwable t, @Nullable OpResult opResult) { Throwable cause; if (null == opResult) { cause = t; } else { assert (opResult instanceof OpResult.ErrorResult); OpResult.ErrorResult errorResult = (OpResult.ErrorResult) opResult; if (KeeperException.Code.OK.intValue() == errorResult.getErr()) { cause = t; } else { cause = KeeperException.create(KeeperException.Code.get(errorResult.getErr())); } } if (null != listener) { listener.onAbort(cause); } } ZKVersionedSetOp(Op op,
                            @Nullable OpListener<Version> opListener);   }### Answer:
@Test(timeout = 60000) public void testAbortNullOpResult() throws Exception { final AtomicReference<Throwable> exception = new AtomicReference<Throwable>(); final CountDownLatch latch = new CountDownLatch(1); ZKVersionedSetOp versionedSetOp = new ZKVersionedSetOp(mock(Op.class), new Transaction.OpListener<Version>() { @Override public void onCommit(Version r) { } @Override public void onAbort(Throwable t) { exception.set(t); latch.countDown(); } }); KeeperException ke = KeeperException.create(KeeperException.Code.SESSIONEXPIRED); versionedSetOp.abortOpResult(ke, null); latch.await(); assertTrue(ke == exception.get()); }
@Test(timeout = 60000) public void testAbortOpResult() throws Exception { final AtomicReference<Throwable> exception = new AtomicReference<Throwable>(); final CountDownLatch latch = new CountDownLatch(1); ZKVersionedSetOp versionedSetOp = new ZKVersionedSetOp(mock(Op.class), new Transaction.OpListener<Version>() { @Override public void onCommit(Version r) { } @Override public void onAbort(Throwable t) { exception.set(t); latch.countDown(); } }); KeeperException ke = KeeperException.create(KeeperException.Code.SESSIONEXPIRED); OpResult opResult = new OpResult.ErrorResult(KeeperException.Code.NONODE.intValue()); versionedSetOp.abortOpResult(ke, opResult); latch.await(); assertTrue(exception.get() instanceof KeeperException.NoNodeException); }