Search in sources :

Example 31 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() {
    super.test_g_v4_out_filterXlang_eq_javaX_backX1X(new GremlinPipeline(g.getVertex(4)).out().filter(new PipeFunction<Vertex, Boolean>() {

        public Boolean compute(Vertex v) {
            return v.getProperty("lang").equals("java");
        }
    }).back(1));
    super.test_g_v4_out_filterXlang_eq_javaX_backX1X(new GremlinPipeline(g.getVertex(4)).optimize(false).out().filter(new PipeFunction<Vertex, Boolean>() {

        public Boolean compute(Vertex v) {
            return v.getProperty("lang").equals("java");
        }
    }).back(1));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) GremlinPipeline(com.tinkerpop.gremlin.java.GremlinPipeline)

Example 32 with Vertex

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

the class BackStepTest method test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX_propertyXnameX.

public void test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX_propertyXnameX() {
    super.test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX_propertyXnameX(new GremlinPipeline(g.getVertex(4)).out().as("here").filter(new PipeFunction<Vertex, Boolean>() {

        public Boolean compute(Vertex v) {
            return v.getProperty("lang").equals("java");
        }
    }).back("here").property("name"));
    super.test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX_propertyXnameX(new GremlinPipeline(g.getVertex(4)).optimize(false).out().as("here").filter(new PipeFunction<Vertex, Boolean>() {

        public Boolean compute(Vertex v) {
            return v.getProperty("lang").equals("java");
        }
    }).back("here").property("name"));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) GremlinPipeline(com.tinkerpop.gremlin.java.GremlinPipeline) PipeFunction(com.tinkerpop.pipes.PipeFunction)

Example 33 with Vertex

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

the class FilterStepTest method test_g_v1_out_filterXage_gt_30X.

public void test_g_v1_out_filterXage_gt_30X() {
    super.test_g_v1_out_filterXage_gt_30X(new GremlinPipeline(g.getVertex(1)).out().filter(new PipeFunction<Vertex, Boolean>() {

        public Boolean compute(Vertex vertex) {
            Integer age = (Integer) vertex.getProperty("age");
            return age != null && age > 30;
        }
    }));
    super.test_g_v1_out_filterXage_gt_30X(new GremlinPipeline(g.getVertex(1)).optimize(false).out().filter(new PipeFunction<Vertex, Boolean>() {

        public Boolean compute(Vertex vertex) {
            Integer age = (Integer) vertex.getProperty("age");
            return age != null && age > 30;
        }
    }));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) GremlinPipeline(com.tinkerpop.gremlin.java.GremlinPipeline) PipeFunction(com.tinkerpop.pipes.PipeFunction)

Example 34 with Vertex

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

the class GroupByStepTest method test_g_V_groupByXlang_nameX.

public void test_g_V_groupByXlang_nameX() {
    Map<?, List<?>> m = new HashMap<Object, List<?>>();
    super.test_g_V_groupByXlang_nameX(new GremlinPipeline(g.getVertices()).groupBy(m, new PipeFunction<Vertex, String>() {

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

        public String compute(Vertex vertex) {
            return (String) vertex.getProperty("name");
        }
    }), (Map) m);
    m = new HashMap<Object, List<?>>();
    super.test_g_V_groupByXlang_nameX(new GremlinPipeline(g.getVertices()).optimize(false).groupBy(m, new PipeFunction<Vertex, String>() {

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

        public String compute(Vertex vertex) {
            return (String) vertex.getProperty("name");
        }
    }), (Map) m);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) GremlinPipeline(com.tinkerpop.gremlin.java.GremlinPipeline) HashMap(java.util.HashMap) List(java.util.List) PipeFunction(com.tinkerpop.pipes.PipeFunction)

Example 35 with Vertex

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

the class SelectStepTest method test_g_v1_asXaX_outXknowsX_asXbX_select.

public void test_g_v1_asXaX_outXknowsX_asXbX_select(final Iterator<Row> pipe) {
    int counter = 0;
    while (pipe.hasNext()) {
        counter++;
        List list = pipe.next();
        assertEquals(list.size(), 2);
        assertEquals(((Vertex) list.get(0)).getId().toString(), "1");
        assertTrue(((Vertex) list.get(1)).getId().toString().equals("2") || ((Vertex) list.get(1)).getId().toString().equals("4"));
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) List(java.util.List)

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