CayenneContextMergeHandler handler = new CayenneContextMergeHandler(context);
// 1. Our context initiated the sync:
// src == channel && postedBy == context
GraphEvent e1 = new GraphEvent(context.getChannel(), context, null);
assertFalse(handler.shouldProcessEvent(e1));
// 2. Another context initiated the sync:
// postedBy != context && source == channel
GraphEvent e2 = new GraphEvent(
context.getChannel(),
new MockObjectContext(),
null);
assertTrue(handler.shouldProcessEvent(e2));
// 2.1 Another object initiated the sync:
// postedBy != context && source == channel
GraphEvent e21 = new GraphEvent(context.getChannel(), new Object(), null);
assertTrue(handler.shouldProcessEvent(e21));
// 3. Another channel initiated the sync:
// postedBy == ? && source != channel
GraphEvent e3 = new GraphEvent(new MockDataChannel(), new Object(), null);
assertFalse(handler.shouldProcessEvent(e3));
// 4. inactive
GraphEvent e4 = new GraphEvent(
context.getChannel(),
new MockObjectContext(),
null);
handler.active = false;
assertFalse(handler.shouldProcessEvent(e4));