use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class GraphDatabaseTest method testNewVertexAndEdgesWithFieldsInOneShoot.
public void testNewVertexAndEdgesWithFieldsInOneShoot() throws IOException {
OrientVertex vertexA = database.addVertex(null, "field1", "value1", "field2", "value2");
Map<String, Object> map = new HashMap<String, Object>();
map.put("field1", "value1");
map.put("field2", "value2");
OrientVertex vertexB = database.addVertex(null, map);
OrientEdge edgeC = database.addEdge(null, vertexA, vertexB, "E");
edgeC.setProperty("edgeF1", "edgeV2");
database.commit();
Assert.assertEquals(vertexA.getProperty("field1"), "value1");
Assert.assertEquals(vertexA.getProperty("field2"), "value2");
Assert.assertEquals(vertexB.getProperty("field1"), "value1");
Assert.assertEquals(vertexB.getProperty("field2"), "value2");
Assert.assertEquals(edgeC.getProperty("edgeF1"), "edgeV2");
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class DistributedSuperNodeTest method onAfterExecution.
@Override
protected void onAfterExecution() {
OrientGraph graph = factory.getTx();
try {
OrientVertex root = graph.getVertex(rootVertexId);
Assert.assertEquals(((OMultiCollectionIterator) root.getEdges(Direction.OUT)).size(), count * serverInstance.size() * writerCount);
} finally {
graph.shutdown();
}
super.onAfterExecution();
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class ServerClusterGraphTest method executeTest.
@Override
protected void executeTest() throws Exception {
{
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server0/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
g.createVertexType("Post");
g.createVertexType("User");
g.createEdgeType("Own");
g.addVertex("class:User");
g.command(new OCommandSQL("insert into Post (content, timestamp) values('test', 1)")).execute();
} finally {
g.shutdown();
}
}
// CHECK VERTEX CREATION ON ALL THE SERVERS
for (int s = 0; s < SERVERS; ++s) {
OrientGraphFactory factory2 = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g2 = factory2.getNoTx();
try {
Iterable<OrientVertex> result = g2.command(new OCommandSQL("select from Post")).execute();
Assert.assertTrue(result.iterator().hasNext());
Assert.assertNotNull(result.iterator().next());
} finally {
g2.shutdown();
}
}
{
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server0/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
g.command(new OCommandSQL("create edge Own from (select from User) to (select from Post)")).execute();
} finally {
g.shutdown();
}
}
// CHECK VERTEX CREATION ON ALL THE SERVERS
for (int s = 0; s < SERVERS; ++s) {
OrientGraphFactory factory2 = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g2 = factory2.getNoTx();
try {
Iterable<OrientVertex> result = g2.command(new OCommandSQL("select from Own")).execute();
Assert.assertTrue(result.iterator().hasNext());
Assert.assertNotNull(result.iterator().next());
result = g2.command(new OCommandSQL("select from Post")).execute();
Assert.assertTrue(result.iterator().hasNext());
final OrientVertex v = result.iterator().next();
Assert.assertNotNull(v);
final Iterable<Edge> inEdges = v.getEdges(Direction.IN);
Assert.assertTrue(inEdges.iterator().hasNext());
Assert.assertNotNull(inEdges.iterator().next());
result = g2.command(new OCommandSQL("select from User")).execute();
Assert.assertTrue(result.iterator().hasNext());
final OrientVertex v2 = result.iterator().next();
Assert.assertNotNull(v2);
final Iterable<Edge> outEdges = v2.getEdges(Direction.OUT);
Assert.assertTrue(outEdges.iterator().hasNext());
Assert.assertNotNull(outEdges.iterator().next());
} finally {
g2.shutdown();
}
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class AbstractServerClusterSQLGraphTest method checkVertex.
protected void checkVertex(OrientGraph graph, OrientVertex v) {
final Iterable<OrientVertex> result = graph.command(new OCommandSQL("select from " + v.getIdentity())).execute();
Assert.assertTrue(result.iterator().hasNext());
final OrientVertex vertex = result.iterator().next();
vertex.reload();
Assert.assertTrue((Boolean) vertex.getProperty("updated"));
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertex in project orientdb by orientechnologies.
the class ServerClusterQueryTest method checkSum.
private void checkSum() {
for (int s = 0; s < SERVERS; ++s) {
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
try {
final Iterable<OrientVertex> result = g.command(new OCommandSQL("select sum(amount) as total from v")).execute(v2.getIdentity());
final Iterator<OrientVertex> it = result.iterator();
Assert.assertTrue(it.hasNext());
final OrientVertex r1 = it.next();
Assert.assertEquals(r1.getProperty("total"), 46);
} finally {
g.shutdown();
}
}
}
Aggregations