@Test
  public void testGraphVHas() {
    Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1");
    Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "name", "a2");

    Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1");
    Vertex b2 = this.sqlgGraph.addVertex(T.label, "B", "name", "b2");
    Vertex b3 = this.sqlgGraph.addVertex(T.label, "B", "name", "b3");
    Vertex b4 = this.sqlgGraph.addVertex(T.label, "B", "name", "b4");

    a1.addEdge("b", b1);
    a1.addEdge("b", b2);
    a1.addEdge("b", b3);
    a1.addEdge("b", b4);

    a2.addEdge("b", b1);
    a2.addEdge("b", b2);
    a2.addEdge("b", b3);
    a2.addEdge("b", b4);

    this.sqlgGraph.tx().commit();

    List<Vertex> bs = this.sqlgGraph.traversal().V().has(T.label, "A").out("b").toList();
    Assert.assertEquals(8, bs.size());
  }
Exemple #2
0
  //    @Test
  public void testLoadSchemaRemembersUncommittedSchemas() throws Exception {

    // Create a new sqlgGraph
    SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration);
    // Not entirely sure what this is for, else it seems hazelcast has not yet distributed the map
    Thread.sleep(1000);
    Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
    Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "b");
    v1.addEdge("friend", v2);
    this.sqlgGraph.tx().commit();

    Vertex v3 = this.sqlgGraph.addVertex(T.label, "Animal", "name", "b");
    Vertex v4 = this.sqlgGraph.addVertex(T.label, "Car", "name", "b");
    Assert.assertEquals(
        1, this.sqlgGraph.traversal().E().has(T.label, "friend").count().next().intValue());
    this.sqlgGraph.tx().commit();

    Assert.assertEquals(1, sqlgGraph1.traversal().E().count().next().intValue());
    Assert.assertEquals(
        1, sqlgGraph1.traversal().E().has(T.label, "friend").count().next().intValue());
    Assert.assertEquals(
        2, sqlgGraph1.traversal().V().has(T.label, "Person").count().next().intValue());

    sqlgGraph1.tx().rollback();
    sqlgGraph1.close();
  }
Exemple #3
0
  // Fails via maven for Hsqldb
  //    @Test
  public void testLazyLoadTableViaEdgeCreation() throws Exception {
    // Create a new sqlgGraph
    SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration);
    Thread.sleep(1000);
    // add a vertex in the old, the new should only see it after a commit
    Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
    Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "b");
    this.sqlgGraph.tx().commit();
    Vertex v11 = sqlgGraph1.addVertex(T.label, "Person", "surname", "ccc");
    Vertex v12 = sqlgGraph1.addVertex(T.label, "Person", "surname", "ccc");
    sqlgGraph1.tx().commit();

    v1.addEdge("friend", v2);
    this.sqlgGraph.tx().commit();

    v11.addEdge("friend", v12);
    sqlgGraph1.tx().commit();

    Assert.assertEquals(1, vertexTraversal(v11).out("friend").count().next().intValue());
    sqlgGraph1.tx().rollback();
    sqlgGraph1.close();
  }
Exemple #4
0
  //    @Test
  public void testLazyLoadTableViaEdgesHas() throws Exception {
    // Create a new sqlgGraph
    SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration);
    // Not entirely sure what this is for, else it seems hazelcast has not yet distributed the map
    Thread.sleep(1000);
    // add a vertex in the old, the new should only see it after a commit
    Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
    Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "b");
    v1.addEdge("friend", v2);
    this.sqlgGraph.tx().commit();
    Assert.assertEquals(
        1, this.sqlgGraph.traversal().E().has(T.label, "friend").count().next().intValue());

    Assert.assertEquals(1, sqlgGraph1.traversal().E().count().next().intValue());
    Assert.assertEquals(
        1, sqlgGraph1.traversal().E().has(T.label, "friend").count().next().intValue());
    Assert.assertEquals(
        2, sqlgGraph1.traversal().V().has(T.label, "Person").count().next().intValue());
    sqlgGraph1.tx().rollback();
    sqlgGraph1.close();
  }