doTestAcrossTransactionBoundaries(tx1, tx2, false);
}
private void doTestAcrossTransactionBoundaries(List<? extends Update> tx1, List<? extends Update> tx2, boolean print) {
HeapBuilder unconflated = new HeapBuilder(tx1);
HeapBuilder conflated = new HeapBuilder(tx1);
unconflated.update(tx2);
UpdateBlock tx2conflated = getConflater().conflate(unconflated.getLastUpdate());
if (print) {
System.out.println("Heap: " + conflated.toString());
System.out.println("Unconflated:");
System.out.println(unconflated.getLastUpdate());
System.out.println("Conflated:");
System.out.println(tx2conflated);
}
conflated.update(tx2conflated);
Assert.assertEquals("Heaps are not equivalent after conflation", unconflated, conflated);
Assert.assertTrue("No conflation took place",
unconflated.getNumUpdatesApplied() > conflated.getNumUpdatesApplied());
if (print) {
System.out.println("Unconflated instructions: " + unconflated.getAllUpdates().list().size());
System.out.println("Conflated instructions: " + conflated.getAllUpdates().list().size());
}
}