Search in sources :

Example 36 with Vertex

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

the class SelectStepTest method test_g_v1_asXaX_outXknowsX_asXbX_selectXaX.

public void test_g_v1_asXaX_outXknowsX_asXbX_selectXaX(final Iterator<Row> pipe) {
    int counter = 0;
    while (pipe.hasNext()) {
        counter++;
        Row list = pipe.next();
        assertEquals(list.size(), 1);
        assertEquals(((Vertex) list.get(0)).getId().toString(), "1");
        assertEquals(((Vertex) list.getColumn("a")).getId().toString(), "1");
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Row(com.tinkerpop.pipes.util.structures.Row)

Example 37 with Vertex

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

the class FilterStepTest method test_g_V_filterXlang_eq_javaX.

public void test_g_V_filterXlang_eq_javaX(Iterator<Vertex> pipe) {
    int counter = 0;
    Set<Vertex> vertices = new HashSet<Vertex>();
    while (pipe.hasNext()) {
        counter++;
        Vertex vertex = pipe.next();
        vertices.add(vertex);
        assertTrue(vertex.getProperty("name").equals("ripple") || vertex.getProperty("name").equals("lop"));
    }
    assertEquals(counter, 2);
    assertEquals(vertices.size(), 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) HashSet(java.util.HashSet)

Example 38 with Vertex

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

the class AggregateStepTest method test_g_v1_aggregateXxX_outXcreatedX_inXcreatedX_exceptXxX.

public void test_g_v1_aggregateXxX_outXcreatedX_inXcreatedX_exceptXxX(final Iterator<Vertex> pipe) {
    int counter = 0;
    while (pipe.hasNext()) {
        counter++;
        Vertex vertex = pipe.next();
        assertTrue(vertex.getProperty("name").equals("peter") || vertex.getProperty("name").equals("josh"));
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex)

Example 39 with Vertex

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

the class GroupCountStepTest method test_g_V_outXcreatedX_groupCountXm__name__plus_2X.

public void test_g_V_outXcreatedX_groupCountXm__name__plus_2X(Iterator<Vertex> pipe, Map<String, Number> m) {
    int counter = 0;
    while (pipe.hasNext()) {
        Vertex vertex = pipe.next();
        counter++;
        assertTrue(vertex.getProperty("name").equals("lop") || vertex.getProperty("name").equals("ripple"));
    }
    assertEquals(counter, 4);
    assertEquals(m.size(), 2);
    assertEquals(m.get("lop"), 6l);
    assertEquals(m.get("ripple"), 2l);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex)

Example 40 with Vertex

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

the class LinkStepTest method test_g_v1_asXaX_outXcreatedX_inXcreatedX_linkBothXcocreator_aX.

public void test_g_v1_asXaX_outXcreatedX_inXcreatedX_linkBothXcocreator_aX(final Iterator<Vertex> pipe) {
    List<Vertex> cocreators = new ArrayList<Vertex>();
    List<Object> ids = new ArrayList<Object>();
    while (pipe.hasNext()) {
        Vertex vertex = pipe.next();
        cocreators.add(vertex);
        ids.add(vertex.getId());
    }
    assertEquals(cocreators.size(), 3);
    assertTrue(ids.contains("1"));
    assertTrue(ids.contains("6"));
    assertTrue(ids.contains("4"));
    for (Vertex vertex : cocreators) {
        if (vertex.getId().equals("1")) {
            assertEquals(vertex.query().direction(Direction.OUT).labels("cocreator").count(), 4);
            assertEquals(vertex.query().direction(Direction.IN).labels("cocreator").count(), 4);
        } else {
            assertEquals(vertex.query().direction(Direction.OUT).labels("cocreator").count(), 1);
            assertEquals(vertex.query().direction(Direction.IN).labels("cocreator").count(), 1);
        }
    }
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) ArrayList(java.util.ArrayList)

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