• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AbstractGremlinTest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.tinkerpop.gremlin.AbstractGremlinTest的典型用法代码示例。如果您正苦于以下问题:Java AbstractGremlinTest类的具体用法?Java AbstractGremlinTest怎么用?Java AbstractGremlinTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AbstractGremlinTest类属于org.apache.tinkerpop.gremlin包,在下文中一共展示了AbstractGremlinTest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testTail

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
@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());
        }
    }
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:21,代码来源:TinkerpopTest.java


示例2: shouldConstructDetachedEdge

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
@Test
public void shouldConstructDetachedEdge() throws IOException {
    Graph g = this.sqlgGraph;
    final GraphReader reader = GryoReader.build()
            .mapper(g.io(GryoIo.build()).mapper().create())
            .create();
    try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/tinkerpop-modern.kryo")) {
        reader.readGraph(stream, g);
    }
    assertModernGraph(g, true, false);
    Edge e = g.traversal().E(convertToEdgeId("marko", "knows", "vadas")).next();
    e.property("year", 2002);
    g.tx().commit();
    e = g.traversal().E(convertToEdgeId("marko", "knows", "vadas")).next();
    final DetachedEdge detachedEdge = DetachedFactory.detach(e, true);
    Assert.assertEquals(convertToEdgeId("marko", "knows", "vadas"), detachedEdge.id());

    Assert.assertEquals("knows", detachedEdge.label());
    Assert.assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.OUT).next().getClass());
    Assert.assertEquals(convertToVertexId("marko"), detachedEdge.vertices(Direction.OUT).next().id());
    Assert.assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());
    Assert.assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.IN).next().getClass());
    Assert.assertEquals(convertToVertexId("vadas"), detachedEdge.vertices(Direction.IN).next().id());
    Assert.assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());

    Assert.assertEquals(2, IteratorUtils.count(detachedEdge.properties()));
    Assert.assertEquals(1, IteratorUtils.count(detachedEdge.properties("year")));
    Assert.assertEquals(0.5d, detachedEdge.properties("weight").next().value());
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:30,代码来源:TestLoadEdge.java


示例3: shouldReferenceVertexWhenRemoved

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
@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(ReferenceFactory.class);

    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));
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:31,代码来源:TestDropStep.java


示例4: g_V_chooseXlabel_eq_person__unionX__out_lang__out_nameX__in_labelX

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
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));

}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:16,代码来源:TinkerpopTest.java


示例5: loadModern

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
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());
    }
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:10,代码来源:BaseTest.java


示例6: loadGratefulDead

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
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());
    }
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:10,代码来源:BaseTest.java


示例7: beforeTestExecution

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
@Override
public boolean beforeTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
    unloadSugar();
    SugarLoader.load();
    return true;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:7,代码来源:GroovyProcessComputerSuite.java


示例8: afterTestExecution

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
@Override
public void afterTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
    unloadSugar();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:GroovyProcessComputerSuite.java


示例9: shouldWriteGratefulDead

import org.apache.tinkerpop.gremlin.AbstractGremlinTest; //导入依赖的package包/类
/**
 * This test helps with data conversions on Grateful Dead.  No Assertions...run as needed. Never read from the
 * GraphML source as it will always use a String identifier.
 */
@Test
public void shouldWriteGratefulDead() throws IOException {
    final Graph g = TinkerGraph.open();

    final GraphReader reader = GryoReader.build().create();
    try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead.kryo")) {
        reader.readGraph(stream, g);
    }

    /* keep this hanging around because changes to gryo format will need grateful dead generated from json so you can generate the gio
    final GraphSONMapper mapper = GraphSONMapper.build().embedTypes(true).create();
    final GraphReader reader = org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.build().mapper(mapper).create();
    try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/org/apache/tinkerpop/gremlin/structure/io/graphson/grateful-dead-typed.json")) {
        reader.readGraph(stream, g);
    }
    */

    final Graph ng = TinkerGraph.open();
    g.traversal().V().sideEffect(ov -> {
        final Vertex v = ov.get();
        if (v.label().equals("song"))
            ng.addVertex(T.id, Integer.parseInt(v.id().toString()), T.label, "song", "name", v.value("name"), "performances", v.property("performances").orElse(0), "songType", v.property("songType").orElse(""));
        else if (v.label().equals("artist"))
            ng.addVertex(T.id, Integer.parseInt(v.id().toString()), T.label, "artist", "name", v.value("name"));
        else
            throw new RuntimeException("damn");
    }).iterate();

    g.traversal().E().sideEffect(oe -> {
        final Edge e = oe.get();
        final Vertex v2 = ng.traversal().V(Integer.parseInt(e.inVertex().id().toString())).next();
        final Vertex v1 = ng.traversal().V(Integer.parseInt(e.outVertex().id().toString())).next();

        if (e.label().equals("followedBy"))
            v1.addEdge("followedBy", v2, T.id, Integer.parseInt(e.id().toString()), "weight", e.value("weight"));
        else if (e.label().equals("sungBy"))
            v1.addEdge("sungBy", v2, T.id, Integer.parseInt(e.id().toString()));
        else if (e.label().equals("writtenBy"))
            v1.addEdge("writtenBy", v2, T.id, Integer.parseInt(e.id().toString()));
        else
            throw new RuntimeException("bah");

    }).iterate();

    final OutputStream os = new FileOutputStream(tempPath + "grateful-dead.kryo");
    GryoWriter.build().create().writeGraph(os, ng);
    os.close();

    final OutputStream os2 = new FileOutputStream(tempPath + "grateful-dead.json");
    GraphSONWriter.build().mapper(GraphSONMapper.build().create()).create().writeGraph(os2, g);
    os2.close();

    final OutputStream os3 = new FileOutputStream(tempPath + "grateful-dead.xml");
    GraphMLWriter.build().create().writeGraph(os3, g);
    os3.close();

    final OutputStream os4 = new FileOutputStream(tempPath + "grateful-dead-typed.json");
    GraphSONWriter.build().mapper(GraphSONMapper.build().embedTypes(true).create()).create().writeGraph(os4, g);
    os4.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:65,代码来源:IoDataGenerationTest.java



注:本文中的org.apache.tinkerpop.gremlin.AbstractGremlinTest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RefPattern类代码示例发布时间:2022-05-23
下一篇:
Java WXBridgeManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap