use of com.tinkerpop.blueprints.util.wrappers.event.listener.GraphChangedListener in project blueprints by tinkerpop.
the class EventGraphTest method testFireEdgeRemovedAndValidateProperties.
public void testFireEdgeRemovedAndValidateProperties() {
final List<Boolean> fired = new ArrayList<Boolean>();
graph.addListener(new GraphChangedListener() {
@Override
public void vertexAdded(Vertex vertex) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void vertexPropertyChanged(Vertex vertex, String key, Object oldValue, Object setValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void vertexPropertyRemoved(Vertex vertex, String key, Object removedValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void vertexRemoved(Vertex vertex, Map<String, Object> props) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void edgeAdded(Edge edge) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void edgePropertyChanged(Edge edge, String key, Object oldValue, Object setValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void edgePropertyRemoved(Edge edge, String key, Object removedValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void edgeRemoved(Edge edge, Map<String, Object> props) {
assertTrue(props.containsKey("weight"));
assertEquals(0.5f, props.get("weight"));
fired.add(true);
}
});
final Edge e = createEdge();
e.setProperty("weight", 0.5f);
graph.removeEdge(e);
assertEquals(1, fired.size());
assertTrue(fired.get(0));
}
use of com.tinkerpop.blueprints.util.wrappers.event.listener.GraphChangedListener 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.GraphChangedListener in project blueprints by tinkerpop.
the class EventGraphTest method testFireVertexRemovedAndValidateProperties.
public void testFireVertexRemovedAndValidateProperties() {
final List<Boolean> fired = new ArrayList<Boolean>();
graph.addListener(new GraphChangedListener() {
@Override
public void vertexAdded(Vertex vertex) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void vertexPropertyChanged(Vertex vertex, String key, Object oldValue, Object setValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void vertexPropertyRemoved(Vertex vertex, String key, Object removedValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void vertexRemoved(Vertex vertex, Map<String, Object> props) {
assertTrue(props.containsKey("name"));
assertEquals("marko", props.get("name"));
fired.add(true);
}
@Override
public void edgeAdded(Edge edge) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void edgePropertyChanged(Edge edge, String key, Object oldValue, Object setValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void edgePropertyRemoved(Edge edge, String key, Object removedValue) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void edgeRemoved(Edge edge, Map<String, Object> props) {
//To change body of implemented methods use File | Settings | File Templates.
}
});
Vertex vertex = createVertex();
vertex.setProperty("name", "marko");
graph.removeVertex(vertex);
assertEquals(1, fired.size());
assertTrue(fired.get(0));
}
use of com.tinkerpop.blueprints.util.wrappers.event.listener.GraphChangedListener 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);
}
Aggregations