### Question:
TransactionWatcher { public TransactionWatcher(Arbitrator arbitrator) { this.arbitrator = arbitrator; } TransactionWatcher(Arbitrator arbitrator);  TransactionWatcher(ServerContext context); void runQuietly(String ztxBulk, long tid, Runnable task); T run(String ztxBulk, long tid, Callable<T> callable); boolean isActive(long tid);  }### Answer:
@Test public void testTransactionWatcher() throws Exception { final String txType = "someName"; final long txid = 7; final SimpleArbitrator sa = new SimpleArbitrator(); final TransactionWatcher txw = new TransactionWatcher(sa); sa.start(txType, txid); try { sa.start(txType, txid); fail("simple arbitrator did not throw an exception"); } catch (Exception ex) { } txw.isActive(txid); assertFalse(txw.isActive(txid)); txw.run(txType, txid, () -> { assertTrue(txw.isActive(txid)); return null; }); assertFalse(txw.isActive(txid)); assertFalse(sa.transactionComplete(txType, txid)); sa.stop(txType, txid); assertFalse(sa.transactionAlive(txType, txid)); assertFalse(sa.transactionComplete(txType, txid)); sa.cleanup(txType, txid); assertTrue(sa.transactionComplete(txType, txid)); try { txw.run(txType, txid, () -> { fail("Should not be able to start a new work on a discontinued transaction"); return null; }); fail("work against stopped transaction should fail"); } catch (Exception ex) { } final long txid2 = 9; sa.start(txType, txid2); txw.run(txType, txid2, () -> { assertTrue(txw.isActive(txid2)); sa.stop(txType, txid2); try { txw.run(txType, txid2, () -> { fail("Should not be able to start a new work on a discontinued transaction"); return null; }); fail("work against a stopped transaction should fail"); } catch (Exception ex) { } assertTrue(txw.isActive(txid2)); return null; }); }