@Test public void testNestedTransactions() { Vertex v1 = graph.addVertex(); newTx(); Vertex v2 = tx.addVertex(); v2.property("name", "foo"); tx.commit(); v1.addEdge("related", graph.traversal().V(v2).next()); graph.tx().commit(); assertCount(1, v1.edges(OUT)); }
EdgeLabel knows = tx.makeEdgeLabel("knows").make(); TitanVertex n1 = tx.addVertex("weight", 10.5); newTx();
newTx(); v21 = getV(tx, v21); tx.makeEdgeLabel("link").unidirected().make(); TitanVertex v3 = tx.addVertex(); v21.addEdge("link", v3); newTx(); v21 = getV(tx, v21); v3 = getOnlyElement(v21.query().direction(Direction.OUT).labels("link").vertices()); assertFalse(v3.isRemoved()); v3.remove(); newTx(); v21 = getV(tx, v21); v3 = getOnlyElement(v21.query().direction(Direction.OUT).labels("link").vertices()); assertFalse(v3.isRemoved()); newTx();
newTx(); evaluateQuery(tx.query().has("name", "v1"), ElementCategory.VERTEX, 1, new boolean[]{false, true}); tx2 = graph2.newTransaction(); tx3.addVertex("name", "v2"); tx3.commit(); newTx(); tx.addVertex("name", "v3"); tx.commit(); tx2.commit(); newTx(); evaluateQuery(tx.query().has("name", "v1"), ElementCategory.VERTEX, 0, new boolean[]{true, true}, "theIndex"); evaluateQuery(tx.query().has("name", "v2"), ElementCategory.VERTEX, 1, new boolean[]{true, true}, "theIndex");
true); // True makes the index on names unique. Test fails when this is true. newTx(); finishSchema();
/** * This test exercises different types of updates against cardinality restricted properties * to ensure that the resulting behavior is fully consistent. */ @Test public void testPropertyCardinality() { PropertyKey uid = mgmt.makePropertyKey("uid").dataType(Long.class).cardinality(Cardinality.SINGLE).make(); PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make(); mgmt.buildIndex("byUid", Vertex.class).addKey(uid).unique().buildCompositeIndex(); mgmt.buildIndex("byName", Vertex.class).addKey(name).buildCompositeIndex(); finishSchema(); TitanVertex v1 = tx.addVertex(); v1.property("name", "name1"); TitanVertex v2 = tx.addVertex(); v2.property("uid", 512); newTx(); v1 = tx.getVertex(v1.longId()); v1.property("name", "name2"); //Ensure that the old index record gets removed v2 = tx.getVertex(v2.longId()); v2.property("uid", 512); //Ensure that replacement is allowed newTx(); assertCount(0, tx.query().has("name", "name1").vertices()); assertCount(1, tx.query().has("name", "name2").vertices()); assertCount(1, tx.query().has("uid", 512).vertices()); }
v.addEdge("knows", v, "time", 11); newTx(); v = getOnlyElement(tx.query().has("time", 5).vertices()); assertNotNull(v); assertCount(1, v.query().direction(Direction.IN).labels("knows").edges()); assertCount(1, v.query().direction(Direction.OUT).labels("knows").has("time", 11).edges()); newTx(); newTx(); v = getOnlyElement(tx.query().has("time", 5).vertices()); assertNotNull(v);
v.addEdge("friend", o, "time", i); newTx(); evaluateQuery(tx.query().has("name", "v105"), ElementCategory.VERTEX, 0, new boolean[]{false, true}); newTx(); mgmt.buildIndex("bySensorReading", Vertex.class).addKey(name).buildCompositeIndex(); finishSchema(); newTx(); newTx(); v = getV(tx, v); for (int i = 200; i < 210; i++) { v.addEdge("friend", o, "time", i); newTx(); newTx(); finishSchema(); newTx();
newTx(); v1 = tx.getVertex(v1.longId());
@Test public void testVertexDeletion() throws Exception { TitanKey name = makeUniqueStringPropertyKey("name"); newTx(); TitanVertex v = tx.addVertex(); TitanProperty p = v.addProperty("name", "oldName"); newTx(); TitanVertex v1 = tx.getVertex(v.getID()); tx.removeVertex(v1); newTx(); if (graph.getFeatures().supportsVertexIteration) { int count = 0; for (Vertex vertex : tx.getVertices()) count++; assertEquals(0, count); } }
newTx(); v1 = tx.getVertex(v1);