RecordingTransaction extends RecordingTransactionBase implements Transaction { public static RecordingTransaction wrap(Transaction tx) { return new RecordingTransaction(tx); } private  RecordingTransaction(Transaction tx); private  RecordingTransaction(Transaction tx, Predicate<LogEntry> filter); @Override void commit(); @Override void close(); static RecordingTransaction wrap(Transaction tx); static RecordingTransaction wrap(Transaction tx, Predicate<LogEntry> filter);  }
@Test public void testTypedTx() { TypedTransaction ttx = tl.wrap(rtx); ttx.mutate().row("r5").fam("cf5").qual("cq5").set("1"); ttx.mutate().row("r6").fam("cf6").qual("cq6").set("1"); List<LogEntry> entries = rtx.getTxLog().getLogEntries(); Assert.assertEquals(2, entries.size()); Assert.assertEquals("LogEntry{op=SET, row=r5, col=cf5 cq5 , value=1}", entries.get(0).toString()); Assert.assertEquals("LogEntry{op=SET, row=r6, col=cf6 cq6 , value=1}", entries.get(1).toString()); }
@Test public void testFilter() { rtx = RecordingTransaction.wrap(tx, le -> le.getColumn().getFamily().toString().equals("cfa")); TypedTransaction ttx = tl.wrap(rtx); ttx.mutate().row("r1").fam("cfa").qual("cq1").set("1"); ttx.mutate().row("r2").fam("cfb").qual("cq2").set("2"); ttx.mutate().row("r3").fam("cfa").qual("cq3").set("3"); List<LogEntry> entries = rtx.getTxLog().getLogEntries(); Assert.assertEquals(2, entries.size()); Assert.assertEquals("LogEntry{op=SET, row=r1, col=cfa cq1 , value=1}", entries.get(0).toString()); Assert.assertEquals("LogEntry{op=SET, row=r3, col=cfa cq3 , value=3}", entries.get(1).toString()); }