Statement s2 = base.createStatement(ar, pr, "2");
Statement s3 = base.createStatement(ar, pr, "3");
Statement s4 = base.createStatement(ar, pr, "4");
Statement s5 = base.createStatement(ar, pr, "5");
MonitorModel monitor = new MonitorModel(base);
RecordingModelListener listener = new RecordingModelListener();
monitor.register(listener);
// base data
base.add(s1);
base.add(s2);
base.add(s3);
// Test changes from empty
List<Statement> additions = new ArrayList<Statement>();
List<Statement> deletions = new ArrayList<Statement>();
monitor.snapshot(additions, deletions);
TestUtil.assertIteratorValues(this, additions.iterator(), new Object[] {s1, s2, s3});
TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[] {});
listener.assertHas(new Object[] {"addList", additions, "removeList", deletions});
listener.clear();
// Make some new changes
base.add(s4);
base.add(s5);
base.remove(s1);
base.remove(s2);
additions.clear();
deletions.clear();
monitor.snapshot(additions, deletions);
TestUtil.assertIteratorValues(this, additions.iterator(), new Object[] {s4, s5});
TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[] {s1, s2});
TestUtil.assertIteratorValues(this, monitor.listStatements(), new Object[] {s3, s4, s5});
listener.assertHas(new Object[] {"addList", additions, "removeList", deletions});
listener.clear();
}