use of com.tinkerpop.blueprints.impls.orient.OrientEdge in project orientdb by orientechnologies.
the class DirtyManagerGraph method testLoopOfNewTree.
@Test
public void testLoopOfNewTree() {
OrientGraph graph = new OrientGraph("memory:" + DirtyManagerGraph.class.getSimpleName());
Object prev = OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.getValue();
OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1);
try {
graph.createEdgeType("next");
OrientVertex vertex = graph.addVertex(null);
OrientVertex vertex1 = graph.addVertex(null);
OrientVertex vertex2 = graph.addVertex(null);
OrientVertex vertex3 = graph.addVertex(null);
OrientEdge edge1 = (OrientEdge) vertex.addEdge("next", vertex1);
OrientEdge edge2 = (OrientEdge) vertex1.addEdge("next", vertex2);
OrientEdge edge3 = (OrientEdge) vertex2.addEdge("next", vertex3);
OrientEdge edge4 = (OrientEdge) vertex3.addEdge("next", vertex);
ODocument rec = vertex.getRecord();
ODirtyManager manager = ORecordInternal.getDirtyManager(rec);
List<OIdentifiable> pointed = manager.getPointed(vertex.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge1.getRecord()));
assertTrue(pointed.contains(edge4.getRecord()));
pointed = manager.getPointed(vertex1.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge1.getRecord()));
assertTrue(pointed.contains(edge2.getRecord()));
pointed = manager.getPointed(vertex2.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge2.getRecord()));
assertTrue(pointed.contains(edge3.getRecord()));
pointed = manager.getPointed(vertex3.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(edge3.getRecord()));
assertTrue(pointed.contains(edge4.getRecord()));
pointed = manager.getPointed(edge1.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex.getRecord()));
assertTrue(pointed.contains(vertex1.getRecord()));
pointed = manager.getPointed(edge2.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex1.getRecord()));
assertTrue(pointed.contains(vertex2.getRecord()));
pointed = manager.getPointed(edge3.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex2.getRecord()));
assertTrue(pointed.contains(vertex3.getRecord()));
pointed = manager.getPointed(edge4.getRecord());
assertEquals(2, pointed.size());
assertTrue(pointed.contains(vertex3.getRecord()));
assertTrue(pointed.contains(vertex.getRecord()));
} finally {
OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(prev);
graph.drop();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientEdge in project orientdb by orientechnologies.
the class TestFailOperationOnRemovedElement method testSetPropertyRemovedEdge.
@Test(expected = ORecordNotFoundException.class)
public void testSetPropertyRemovedEdge() {
OrientVertex v = grap.addVertex(null);
OrientVertex v1 = grap.addVertex(null);
OrientEdge e = (OrientEdge) v.addEdge("test", v1);
grap.commit();
e.remove();
e.setProperties("test", "test");
}
use of com.tinkerpop.blueprints.impls.orient.OrientEdge in project orientdb by orientechnologies.
the class TestFailOperationOnRemovedElement method testDoubleRemovedEdge.
@Test(expected = ORecordNotFoundException.class)
public void testDoubleRemovedEdge() {
OrientVertex v = grap.addVertex(null);
OrientVertex v1 = grap.addVertex(null);
OrientEdge e = (OrientEdge) v.addEdge("test", v1);
grap.commit();
e.remove();
e.remove();
}
use of com.tinkerpop.blueprints.impls.orient.OrientEdge in project orientdb by orientechnologies.
the class TestGraphRecovering method testRecoverBrokenGraphAllEdges.
@Test
public void testRecoverBrokenGraphAllEdges() {
final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverBrokenGraphAllEdges");
try {
init(g, false);
for (Edge e : g.getEdges()) {
((OrientEdge) e).getRecord().removeField("out");
((OrientEdge) e).getRecord().save();
}
final TestListener eventListener = new TestListener();
new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
Assert.assertEquals(eventListener.scannedEdges, 3);
Assert.assertEquals(eventListener.removedEdges, 3);
Assert.assertEquals(eventListener.scannedVertices, 3);
Assert.assertEquals(eventListener.scannedLinks, 6);
Assert.assertEquals(eventListener.removedLinks, 6);
Assert.assertEquals(eventListener.repairedVertices, 3);
} finally {
g.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientEdge in project orientdb by orientechnologies.
the class SQLGraphFunctionsTest method testGremlinTraversal.
@Test
public void testGremlinTraversal() {
OGremlinHelper.global().create();
graph.setAutoStartTx(false);
graph.commit();
graph.command(new OCommandSQL("create class tc1 extends V clusters 1")).execute();
graph.command(new OCommandSQL("create class edge1 extends E clusters 1")).execute();
graph.setAutoStartTx(true);
OrientVertex v1 = graph.command(new OCommandSQL("create vertex tc1 SET id='1', name='name1'")).execute();
OrientVertex v2 = graph.command(new OCommandSQL("create vertex tc1 SET id='2', name='name2'")).execute();
graph.commit();
int tc1Id = graph.getRawGraph().getClusterIdByName("tc1");
int edge1Id = graph.getRawGraph().getClusterIdByName("edge1");
Iterable<OrientEdge> e = graph.command(new OCommandSQL("create edge edge1 from #" + tc1Id + ":0 to #" + tc1Id + ":1 set f='fieldValue';")).execute();
graph.commit();
List<ODocument> result = graph.getRawGraph().query(new OSQLSynchQuery<ODocument>("select gremlin('current.outE') from tc1"));
Assert.assertEquals(2, result.size());
ODocument firstItem = result.get(0);
List<OrientEdge> firstResult = firstItem.field("gremlin");
Assert.assertEquals(1, firstResult.size());
OrientEdge edge = firstResult.get(0);
Assert.assertEquals(new ORecordId(edge1Id, 0), (ORID) edge.getId());
ODocument secondItem = result.get(1);
List<OrientEdge> secondResult = secondItem.field("gremlin");
Assert.assertTrue(secondResult.isEmpty());
OGremlinHelper.global().destroy();
}
Aggregations