Search in sources :

Example 41 with Vertex

use of com.tinkerpop.blueprints.Vertex in project gremlin by tinkerpop.

the class UtilitiesTest method test_g_v1_out_nextX1X.

public void test_g_v1_out_nextX1X(List<Vertex> vertices) {
    assertEquals(vertices.size(), 1);
    Vertex vertex = vertices.get(0);
    List<String> names = Arrays.asList("josh", "vadas", "lop");
    assertTrue(names.contains((String) vertex.getProperty("name")));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex)

Example 42 with Vertex

use of com.tinkerpop.blueprints.Vertex in project gremlin by tinkerpop.

the class UtilitiesTest method test_g_v1_out_toList.

public void test_g_v1_out_toList(List<Vertex> vertices) {
    assertEquals(vertices.size(), 3);
    List<String> names = new ArrayList<String>();
    for (Vertex vertex : vertices) {
        names.add((String) vertex.getProperty("name"));
    }
    assertEquals(names.size(), 3);
    assertTrue(names.contains("josh"));
    assertTrue(names.contains("lop"));
    assertTrue(names.contains("vadas"));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) ArrayList(java.util.ArrayList)

Example 43 with Vertex

use of com.tinkerpop.blueprints.Vertex in project gremlin by tinkerpop.

the class BackStepTest method test_g_v4_out_filterXlang_eq_javaX_backX1X.

public void test_g_v4_out_filterXlang_eq_javaX_backX1X(Iterator<?> pipe) {
    int counter = 0;
    while (pipe.hasNext()) {
        counter++;
        Vertex vertex = (Vertex) pipe.next();
        assertEquals(vertex.getProperty("lang"), "java");
        assertTrue(vertex.getProperty("name").equals("ripple") || vertex.getProperty("name").equals("lop"));
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex)

Example 44 with Vertex

use of com.tinkerpop.blueprints.Vertex in project gremlin by tinkerpop.

the class TableStepTest method test_g_v1_asXaX_out_propertyXnameX_asXbX_tableXname_lengthX_cap.

public void test_g_v1_asXaX_out_propertyXnameX_asXbX_tableXname_lengthX_cap() {
    super.test_g_v1_asXaX_out_propertyXnameX_asXbX_tableXname_lengthX_cap(new GremlinPipeline(g.getVertex(1)).as("a").out().property("name").as("b").table(new Table(), new PipeFunction<Vertex, String>() {

        public String compute(Vertex vertex) {
            return (String) vertex.getProperty("name");
        }
    }, new PipeFunction<String, Integer>() {

        public Integer compute(String name) {
            return name.length();
        }
    }).cap());
    super.test_g_v1_asXaX_out_propertyXnameX_asXbX_tableXname_lengthX_cap(new GremlinPipeline(g.getVertex(1)).optimize(false).as("a").out().property("name").as("b").table(new Table(), new PipeFunction<Vertex, String>() {

        public String compute(Vertex vertex) {
            return (String) vertex.getProperty("name");
        }
    }, new PipeFunction<String, Integer>() {

        public Integer compute(String name) {
            return name.length();
        }
    }).cap());
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) GremlinPipeline(com.tinkerpop.gremlin.java.GremlinPipeline) Table(com.tinkerpop.pipes.util.structures.Table)

Example 45 with Vertex

use of com.tinkerpop.blueprints.Vertex in project frames by tinkerpop.

the class FramedGraphTest method testCreateFrame.

public void testCreateFrame() {
    Graph graph = new TinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person person = framedGraph.addVertex(null, Person.class);
    assertEquals(person.asVertex(), graph.getVertices().iterator().next());
    int counter = 0;
    for (Vertex v : graph.getVertices()) {
        counter++;
    }
    assertEquals(counter, 1);
    counter = 0;
    for (Edge e : graph.getEdges()) {
        counter++;
    }
    assertEquals(counter, 0);
    Person person2 = framedGraph.addVertex("aPerson", Person.class);
    assertEquals(person2.asVertex().getId(), "aPerson");
    counter = 0;
    for (Vertex v : graph.getVertices()) {
        counter++;
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Person(com.tinkerpop.frames.domain.classes.Person) Edge(com.tinkerpop.blueprints.Edge)

Aggregations

Vertex (com.tinkerpop.blueprints.Vertex)406 Test (org.junit.Test)119 Edge (com.tinkerpop.blueprints.Edge)111 Graph (com.tinkerpop.blueprints.Graph)85 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)84 JSONObject (org.codehaus.jettison.json.JSONObject)51 HashSet (java.util.HashSet)49 ArrayList (java.util.ArrayList)40 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)37 GremlinPipeline (com.tinkerpop.gremlin.java.GremlinPipeline)28 HashMap (java.util.HashMap)25 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)22 JSONArray (org.codehaus.jettison.json.JSONArray)20 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)19 Test (org.testng.annotations.Test)16 KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)15 Map (java.util.Map)15 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)14 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)13 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)11