use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class EdgeIndexingTest method testOutLinksUniquenessFour.
/**
* Test that "out_vertex" has singe and only single edge to "in_vertex". This only possible if edges are not lightweight edges.
*/
@Test
public void testOutLinksUniquenessFour() {
final String url = "memory:" + this.getClass().getSimpleName();
OrientGraph graph = new OrientGraph(url, "admin", "admin", false);
graph.drop();
graph = new OrientGraph(url, "admin", "admin", false);
OClass edgeType = graph.createEdgeType("link");
edgeType.createProperty("in", OType.LINK);
edgeType.createProperty("out", OType.LINK);
edgeType.createIndex("uniqueLinkIndex", "unique", "in", "out");
graph.setAutoStartTx(true);
Vertex vertexOutOne = graph.addVertex(null);
Vertex vertexInOne = graph.addVertex(null);
Vertex vertexInTwo = graph.addVertex(null);
vertexOutOne.addEdge("link", vertexInOne);
vertexOutOne.addEdge("link", vertexInTwo);
vertexOutOne.addEdge("link", vertexInOne);
try {
graph.commit();
Assert.fail();
// in vertex can be linked by only one out vertex.
} catch (ORecordDuplicatedException e) {
}
graph.drop();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class ORidBagTest method stackOverflowDuringToString.
public void stackOverflowDuringToString() {
final OrientGraph graph = new OrientGraph(database);
OrientVertex a = graph.addVertex("A");
OrientVertex b = graph.addVertex("B");
OrientVertex c = graph.addVertex("C");
a.addEdge("link", b);
a.addEdge("link", c);
b.addEdge("link", a);
b.addEdge("link", c);
c.addEdge("link", a);
c.addEdge("link", b);
// System.out.println("A: " + a.getRecord());
// System.out.println("B: " + b.getRecord());
// System.out.println("C: " + c.getRecord());
database.commit();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class TransactionConsistencyTest method testConsistencyOnDelete.
@Test
public void testConsistencyOnDelete() {
final OrientGraph graph = new OrientGraph(url);
if (graph.getVertexType("Foo") == null)
graph.createVertexType("Foo");
try {
// Step 1
// Create several foo's
graph.addVertex("class:Foo", "address", "test1");
graph.addVertex("class:Foo", "address", "test2");
graph.addVertex("class:Foo", "address", "test3");
graph.commit();
// just show what is there
List<ODocument> result = graph.getRawGraph().query(new OSQLSynchQuery<ODocument>("select * from Foo"));
// for (ODocument d : result) {
// System.out.println("Vertex: " + d);
// }
// remove those foos in a transaction
// Step 3a
result = graph.getRawGraph().query(new OSQLSynchQuery<ODocument>("select * from Foo where address = 'test1'"));
Assert.assertEquals(result.size(), 1);
// Step 4a
graph.removeVertex(graph.getVertex(result.get(0)));
// Step 3b
result = graph.getRawGraph().query(new OSQLSynchQuery<ODocument>("select * from Foo where address = 'test2'"));
Assert.assertEquals(result.size(), 1);
// Step 4b
graph.removeVertex(graph.getVertex(result.get(0)));
// Step 3c
result = graph.getRawGraph().query(new OSQLSynchQuery<ODocument>("select * from Foo where address = 'test3'"));
Assert.assertEquals(result.size(), 1);
// Step 4c
graph.removeVertex(graph.getVertex(result.get(0)));
// Step 6
graph.commit();
// just show what is there
result = graph.getRawGraph().query(new OSQLSynchQuery<ODocument>("select * from Foo"));
// for (ODocument d : result) {
// System.out.println("Vertex: " + d);
// }
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class TransactionConsistencyTest method deletesWithinTransactionArentWorking.
@Test
public void deletesWithinTransactionArentWorking() throws IOException {
OrientGraph graph = new OrientGraph(url);
graph.setUseLightweightEdges(false);
try {
if (graph.getVertexType("Foo") == null)
graph.createVertexType("Foo");
if (graph.getVertexType("Bar") == null)
graph.createVertexType("Bar");
if (graph.getVertexType("Sees") == null)
graph.createEdgeType("Sees");
// Commenting out the transaction will result in the test succeeding.
ODocument foo = graph.addVertex("class:Foo", "prop", "test1").getRecord();
// Comment out these two lines and the test will succeed. The issue appears to be related to an edge
// connecting a deleted vertex during a transaction
ODocument bar = graph.addVertex("class:Bar", "prop", "test1").getRecord();
ODocument sees = graph.addEdge(null, graph.getVertex(foo), graph.getVertex(bar), "Sees").getRecord();
graph.commit();
List<ODocument> foos = graph.getRawGraph().query(new OSQLSynchQuery("select * from Foo"));
Assert.assertEquals(foos.size(), 1);
graph.removeVertex(graph.getVertex(foos.get(0)));
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class TraverseTest method init.
@BeforeClass
public void init() {
OrientGraph graph = new OrientGraph(database);
graph.setUseLightweightEdges(false);
graph.createVertexType("Movie");
graph.createVertexType("Actor");
tomCruise = graph.addVertex("class:Actor", "name", "Tom Cruise").getRecord();
totalElements++;
megRyan = graph.addVertex("class:Actor", "name", "Meg Ryan").getRecord();
totalElements++;
nicoleKidman = graph.addVertex("class:Actor", "name", "Nicole Kidman", "attributeWithDotValue", "a.b").getRecord();
totalElements++;
ODocument topGun = graph.addVertex("class:Movie", "name", "Top Gun", "year", 1986).getRecord();
totalElements++;
ODocument missionImpossible = graph.addVertex("class:Movie", "name", "Mission: Impossible", "year", 1996).getRecord();
totalElements++;
ODocument youHaveGotMail = graph.addVertex("class:Movie", "name", "You've Got Mail", "year", 1998).getRecord();
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(topGun), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(megRyan), graph.getVertex(topGun), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(missionImpossible), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(megRyan), graph.getVertex(youHaveGotMail), "actorIn");
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(megRyan), "friend");
totalElements++;
graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(nicoleKidman), "married").setProperty("year", 1990);
totalElements++;
graph.commit();
}
Aggregations