org.apache.tinkerpop.gremlin.AbstractGremlinTest Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.AbstractGremlinTest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TinkerpopTest.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void testTail() throws IOException {
    Graph graph = this.sqlgGraph;
    final GraphReader reader = GryoReader.build()
            .mapper(graph.io(GryoIo.build()).mapper().create())
            .create();
    try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/tinkerpop-modern.kryo")) {
        reader.readGraph(stream, graph);
    }
    assertModernGraph(graph, true, false);
    GraphTraversalSource g = graph.traversal();
    int tail = 0;
    for (int i = 1; i < 72; i++) {
        tail = i;
        List<Vertex> vertices = g.V().repeat(both()).times(3).tail(tail).toList();
        if (tail != vertices.size()) {
            System.out.println("expected " + tail + " found " + vertices.size());
        }
    }
}
 
Example #2
Source File: TestDropStep.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void shouldReferenceVertexWhenRemoved() {
    final AtomicBoolean triggered = new AtomicBoolean(false);
    final Vertex v = this.sqlgGraph.addVertex();
    final String label = v.label();
    final Object id = v.id();

    final MutationListener listener = new AbstractMutationListener() {
        @Override
        public void vertexRemoved(final Vertex element) {
            Assert.assertThat(element, IsInstanceOf.instanceOf(ReferenceVertex.class));
            Assert.assertEquals(id, element.id());
            Assert.assertEquals(label, element.label());
            triggered.set(true);
        }
    };
    final EventStrategy.Builder builder = EventStrategy.build().addListener(listener)
        .detach(EventStrategy.Detachment.REFERENCE);

    if (this.sqlgGraph.features().graph().supportsTransactions())
        builder.eventQueue(new EventStrategy.TransactionalEventQueue(this.sqlgGraph));

    final EventStrategy eventStrategy = builder.create();
    final GraphTraversalSource gts = this.sqlgGraph.traversal().withStrategies(eventStrategy);

    gts.V(v).drop().iterate();
    this.sqlgGraph.tx().commit();

    AbstractGremlinTest.assertVertexEdgeCounts(this.sqlgGraph, 0, 0);
    Assert.assertThat(triggered.get(), CoreMatchers.is(true));
}
 
Example #3
Source File: TinkerpopTest.java    From sqlg with MIT License 5 votes vote down vote up
public void g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX() throws IOException {
    Graph graph = this.sqlgGraph;
    final GraphReader reader = GryoReader.build()
            .mapper(graph.io(GryoIo.build()).mapper().create())
            .create();
    try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/tinkerpop-modern.kryo")) {
        reader.readGraph(stream, graph);
    }
    assertModernGraph(graph, true, false);
    GraphTraversalSource g = graph.traversal();
    List<Vertex> traversala2 =  g.V().hasId(convertToVertexId("marko")).toList();
    Assert.assertEquals(1, traversala2.size());
    Assert.assertEquals(convertToVertex(graph, "marko"), traversala2.get(0));

}
 
Example #4
Source File: BaseTest.java    From sqlg with MIT License 5 votes vote down vote up
protected void loadModern(SqlgGraph sqlgGraph) {
    Io.Builder<GraphSONIo> builder = GraphSONIo.build(GraphSONVersion.V3_0);
    final GraphReader reader = sqlgGraph.io(builder).reader().create();
    try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/tinkerpop-modern-v3d0.json")) {
        reader.readGraph(stream, sqlgGraph);
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}
 
Example #5
Source File: BaseTest.java    From sqlg with MIT License 5 votes vote down vote up
protected void loadGratefulDead(SqlgGraph sqlgGraph) {
    Io.Builder<GraphSONIo> builder = GraphSONIo.build(GraphSONVersion.V3_0);
    final GraphReader reader = sqlgGraph.io(builder).reader().create();
    try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/grateful-dead-v3d0.json")) {
        reader.readGraph(stream, sqlgGraph);
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}