task.m_calledWith.clear();
// add an overlapping destination
dest.add(new LogDescriptor("gwid", 1, new SortedRangeSet("1-3")));
task.writeDelta(task.calculateDelta(src, dest), null);
assert task.m_calledWith.size() == 1 : "Delta should be 1 instead of: " + task.m_calledWith.size();
RangeIterator i = task.m_calledWith.get(0).getRangeSet().iterator();
assert i.next() == 4 : "Illegal value in SortedRangeSet";
assert i.next() == 5 : "Illegal value in SortedRangeSet";
assert !i.hasNext() : "Illegal value in SortedRangeSet";
task.m_calledWith.clear();
// add a non-overlapping destination
dest.add(new LogDescriptor("gwid", 2, new SortedRangeSet("50-100")));
task.writeDelta(task.calculateDelta(src, dest), null);
assert task.m_calledWith.size() == 1 : "Delta should be 1 instead of: " + task.m_calledWith.size();
i = task.m_calledWith.get(0).getRangeSet().iterator();
assert i.next() == 4 : "Illegal value in SortedRangeSet";
assert i.next() == 5 : "Illegal value in SortedRangeSet";
assert !i.hasNext() : "Illegal value in SortedRangeSet";
task.m_calledWith.clear();
// add non-overlapping source
src.add(new LogDescriptor("gwid", 2, new SortedRangeSet("1-49")));
task.writeDelta(task.calculateDelta(src, dest), null);
assert task.m_calledWith.size() == 2 : "Delta should be 2 instead of: " + task.m_calledWith.size();
task.m_calledWith.clear();
// add a source with gaps
src.add(new LogDescriptor("gwid", 3, new SortedRangeSet("1-10")));
dest.add(new LogDescriptor("gwid", 3, new SortedRangeSet("3,5-8")));
task.writeDelta(task.calculateDelta(src, dest), null);
assert task.m_calledWith.size() == 3 : "Delta should be 3 instead of: " + task.m_calledWith.size();
for (LogDescriptor l : task.m_calledWith) {
if (l.getLogID() == 3) {
i = l.getRangeSet().iterator();
}
}
assert i.next() == 1 : "Illegal value in SortedRangeSet";
assert i.next() == 2 : "Illegal value in SortedRangeSet";
assert i.next() == 4 : "Illegal value in SortedRangeSet";
assert i.next() == 9 : "Illegal value in SortedRangeSet";
assert i.next() == 10 : "Illegal value in SortedRangeSet";
assert !i.hasNext() : "Illegal value in SortedRangeSet";
}