// }
// graph.shutdown();
// }
public void testGettingVerticesAndEdgesWithKeyValue() {
KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
if (graph.getFeatures().supportsVertexIteration && graph.getFeatures().supportsVertexKeyIndex) {
graph.createKeyIndex("name", Vertex.class);
assertEquals(graph.getIndexedKeys(Vertex.class).size(), 1);
assertTrue(graph.getIndexedKeys(Vertex.class).contains("name"));
Vertex v1 = graph.addVertex(null);
v1.setProperty("name", "marko");
v1.setProperty("location", "everywhere");
Vertex v2 = graph.addVertex(null);
v2.setProperty("name", "stephen");
v2.setProperty("location", "everywhere");
assertEquals(count(graph.getVertices("location", "everywhere")), 2);
assertEquals(count(graph.getVertices("name", "marko")), 1);
assertEquals(count(graph.getVertices("name", "stephen")), 1);
assertEquals(graph.getVertices("name", "marko").iterator().next(), v1);
assertEquals(graph.getVertices("name", "stephen").iterator().next(), v2);
}
if (graph.getFeatures().supportsEdgeIteration && graph.getFeatures().supportsEdgeKeyIndex) {
graph.createKeyIndex("place", Edge.class);
assertEquals(graph.getIndexedKeys(Edge.class).size(), 1);
assertTrue(graph.getIndexedKeys(Edge.class).contains("place"));
Edge e1 = graph.addEdge(null, graph.addVertex(null), graph.addVertex(null), graphTest.convertLabel("knows"));
e1.setProperty("name", "marko");
e1.setProperty("place", "everywhere");
Edge e2 = graph.addEdge(null, graph.addVertex(null), graph.addVertex(null), graphTest.convertLabel("knows"));
e2.setProperty("name", "stephen");
e2.setProperty("place", "everywhere");
assertEquals(count(graph.getEdges("place", "everywhere")), 2);
assertEquals(count(graph.getEdges("name", "marko")), 1);
assertEquals(count(graph.getEdges("name", "stephen")), 1);
assertEquals(graph.getEdges("name", "marko").iterator().next(), e1);
assertEquals(graph.getEdges("name", "stephen").iterator().next(), e2);
}
graph.shutdown();
}