use of com.tinkerpop.blueprints.util.wrappers.event.listener.ConsoleGraphChangedListener in project blueprints by tinkerpop.
the class EventGraphTest method testManageListeners.
public void testManageListeners() {
EventGraph graph = this.graph;
ConsoleGraphChangedListener listener1 = new ConsoleGraphChangedListener(graph);
ConsoleGraphChangedListener listener2 = new ConsoleGraphChangedListener(graph);
graph.addListener(listener1);
graph.addListener(listener2);
Iterator<GraphChangedListener> itty = graph.getListenerIterator();
int counter = 0;
while (itty.hasNext()) {
itty.next();
counter++;
}
assertEquals(2, counter);
graph.removeListener(listener2);
itty = graph.getListenerIterator();
counter = 0;
while (itty.hasNext()) {
itty.next();
counter++;
}
assertEquals(1, counter);
graph.removeAllListeners();
itty = graph.getListenerIterator();
counter = 0;
while (itty.hasNext()) {
itty.next();
counter++;
}
assertEquals(0, counter);
}
use of com.tinkerpop.blueprints.util.wrappers.event.listener.ConsoleGraphChangedListener in project blueprints by tinkerpop.
the class EventGraphTest method testWrappedElementUniqueness.
public void testWrappedElementUniqueness() {
graph.addListener(new ConsoleGraphChangedListener(graph));
assertEquals(graph.getVertex(1), graph.getVertex(1));
Set<Vertex> set = new HashSet<Vertex>();
set.add(graph.getVertex(2));
set.add(graph.getVertex(2));
assertEquals(set.size(), 1);
assertEquals(graph.getEdge(7).hashCode(), graph.getEdge(7).hashCode());
assertEquals(graph.getEdge(8), graph.getEdge(8));
}
use of com.tinkerpop.blueprints.util.wrappers.event.listener.ConsoleGraphChangedListener in project blueprints by tinkerpop.
the class EventTransactionalGraphTest method testManageListeners.
public void testManageListeners() {
EventGraph graph = this.graph;
ConsoleGraphChangedListener listener1 = new ConsoleGraphChangedListener(graph);
ConsoleGraphChangedListener listener2 = new ConsoleGraphChangedListener(graph);
graph.addListener(listener1);
graph.addListener(listener2);
Iterator<GraphChangedListener> itty = graph.getListenerIterator();
int counter = 0;
while (itty.hasNext()) {
itty.next();
counter++;
}
assertEquals(2, counter);
graph.removeListener(listener2);
itty = graph.getListenerIterator();
counter = 0;
while (itty.hasNext()) {
itty.next();
counter++;
}
assertEquals(1, counter);
graph.removeAllListeners();
itty = graph.getListenerIterator();
counter = 0;
while (itty.hasNext()) {
itty.next();
counter++;
}
assertEquals(0, counter);
}
use of com.tinkerpop.blueprints.util.wrappers.event.listener.ConsoleGraphChangedListener in project blueprints by tinkerpop.
the class EventTransactionalGraphTest method testEventedGraph.
public void testEventedGraph() {
graph.addListener(new ConsoleGraphChangedListener(graph));
assertTrue(graph.getVertices() instanceof EventVertexIterable);
assertTrue(graph.getEdges() instanceof EventEdgeIterable);
assertEquals(count(graph.getVertices()), 6);
assertEquals(count(graph.getEdges()), 6);
graph.removeVertex(graph.getVertex(1));
assertNull(graph.getVertex(1));
graph.removeEdge(graph.getEdge(10));
assertNull(graph.getEdge(10));
graph.shutdown();
}
Aggregations