/** Tell the event manager that the triple <code>t</code> has been added to the graph. */ public void notifyAdd( Triple t ) { getEventManager().notifyAddTriple( this, t ); }
/** Tell the event manager that the triple <code>t</code> has been added to the graph. */ public void notifyAdd( Triple t ) { getEventManager().notifyAddTriple( this, t ); }
@Override public void add(Triple t) { base.add(t) ; getEventManager().notifyAddTriple(this, t) ; }
@Override public void add(Triple t) { base.add(t) ; getEventManager().notifyAddTriple(this, t) ; }
@Override public void performAdd(Triple t) { if (deletedTriples.contains(t)) { deletedTriples.remove(t); getEventManager().notifyAddTriple(this, t); } else if (containsByEquals(addedGraph,t) || containsByEquals(base, t) ) { // notify even unsuccessful adds - see javadoc for graphlistener getEventManager().notifyAddTriple(this, t); } else { // addedGraph does notification for us. addedGraph.add(t); } }
@Override public void performAdd(Triple t) { if (deletedTriples.contains(t)) { deletedTriples.remove(t); getEventManager().notifyAddTriple(this, t); } else if (containsByEquals(addedGraph,t) || containsByEquals(base, t) ) { // notify even unsuccessful adds - see javadoc for graphlistener getEventManager().notifyAddTriple(this, t); } else { // addedGraph does notification for us. addedGraph.add(t); } }
/** * Test that adding a triple is reported. */ @ContractTest public void testAddTriple() { gem.register(L); gem.notifyAddTriple(mockGraph, SPO); L.assertHas(new Object[] { "add", mockGraph, SPO }); }
/** * Test that adding a triple is reported. */ @ContractTest public void testAddTriple() { gem.register(L); gem.notifyAddTriple(mockGraph, SPO); L.assertHas(new Object[] { "add", mockGraph, SPO }); }
/** * Test that unregistering a listener after registering it results in it not * receiving messages. */ @ContractTest public void testUnregisterWorks() { gem.register(L).unregister(L); gem.notifyAddTriple(mockGraph, SPO); L.assertHas(new Object[] {}); }
/** * Test that registering a listener twice results in the listener receiving * the events twice. */ @ContractTest public void testRegisterTwice() { gem.register(L).register(L); gem.notifyAddTriple(mockGraph, SPO); L.assertHas(new Object[] { "add", mockGraph, SPO, "add", mockGraph, SPO }); }
/** * Test that unregistering a listener after registering it results in it not * receiving messages. */ @ContractTest public void testUnregisterWorks() { gem.register(L).unregister(L); gem.notifyAddTriple(mockGraph, SPO); L.assertHas(new Object[] {}); }
/** * Test that registering a listener twice results in the listener receiving * the events twice. */ @ContractTest public void testRegisterTwice() { gem.register(L).register(L); gem.notifyAddTriple(mockGraph, SPO); L.assertHas(new Object[] { "add", mockGraph, SPO, "add", mockGraph, SPO }); }
/** * Test adding a triple to trigger event. * * @param registerTo * Number of listeners to register. * @param allx */ private void testAddingTriple(int registerTo, ComeAndGoListener... allx) { all = allx; // register addMe for (int i = 0; i < registerTo; i++) { all[i].register(gem); } // start them all for (ComeAndGoListener l : all) { l.start(); } // send the notification. gem.notifyAddTriple(mockGraph, GraphHelper.triple("make a change")); // check them for (ComeAndGoListener l : all) { l.check(); } }
/** * Test adding a triple to trigger event. * * @param registerTo * Number of listeners to register. * @param allx */ private void testAddingTriple(int registerTo, ComeAndGoListener... allx) { all = allx; // register addMe for (int i = 0; i < registerTo; i++) { all[i].register(gem); } // start them all for (ComeAndGoListener l : all) { l.start(); } // send the notification. gem.notifyAddTriple(mockGraph, GraphHelper.triple("make a change")); // check them for (ComeAndGoListener l : all) { l.check(); } }
/** * Test that when 2 listeners are added both receive events. */ @ContractTest public void testTwoListeners() { RecordingGraphListener L1 = new RecordingGraphListener(); RecordingGraphListener L2 = new RecordingGraphListener(); gem.register(L1).register(L2); gem.notifyAddTriple(mockGraph, SPO); L2.assertHas(new Object[] { "add", mockGraph, SPO }); L1.assertHas(new Object[] { "add", mockGraph, SPO }); }
/** * Test that when 2 listeners are added both receive events. */ @ContractTest public void testTwoListeners() { RecordingGraphListener L1 = new RecordingGraphListener(); RecordingGraphListener L2 = new RecordingGraphListener(); gem.register(L1).register(L2); gem.notifyAddTriple(mockGraph, SPO); L2.assertHas(new Object[] { "add", mockGraph, SPO }); L1.assertHas(new Object[] { "add", mockGraph, SPO }); }