当前位置: 首页>>代码示例>>Java>>正文


Java EmptyGraph.instance方法代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph.instance方法的典型用法代码示例。如果您正苦于以下问题:Java EmptyGraph.instance方法的具体用法?Java EmptyGraph.instance怎么用?Java EmptyGraph.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph的用法示例。


在下文中一共展示了EmptyGraph.instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldEventOnMutatingSteps

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldEventOnMutatingSteps() {
    final MutationListener listener1 = new ConsoleMutationListener(EmptyGraph.instance());
    final EventStrategy eventStrategy = EventStrategy.build()
            .addListener(listener1).create();

    eventStrategy.apply(traversal.asAdmin());

    final AtomicInteger mutatingStepsFound = new AtomicInteger(0);
    traversal.asAdmin().getSteps().stream()
            .filter(s -> s instanceof Mutating)
            .forEach(s -> {
                final Mutating mutating = (Mutating) s;
                assertEquals(1, mutating.getMutatingCallbackRegistry().getCallbacks().size());
                mutatingStepsFound.incrementAndGet();
            });

    assertEquals(expectedMutatingStepsFound, mutatingStepsFound.get());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:EventStrategyTest.java

示例2: shouldRemoveStepsCorrectly

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldRemoveStepsCorrectly() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    traversal.asAdmin().addStep(new IdentityStep(traversal));
    traversal.asAdmin().addStep(new HasStep(traversal));
    traversal.asAdmin().addStep(new LambdaFilterStep(traversal, traverser -> true));

    traversal.asAdmin().addStep(new PropertiesStep(traversal, PropertyType.VALUE, "marko"));
    traversal.asAdmin().removeStep(3);
    validateToyTraversal(traversal);

    traversal.asAdmin().addStep(0, new PropertiesStep(traversal, PropertyType.PROPERTY, "marko"));
    traversal.asAdmin().removeStep(0);
    validateToyTraversal(traversal);

    traversal.asAdmin().removeStep(1);
    traversal.asAdmin().addStep(1, new HasStep(traversal));
    validateToyTraversal(traversal);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:TraversalHelperTest.java

示例3: shouldNotAllowBytecodeEvalWithInvalidBinding

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void shouldNotAllowBytecodeEvalWithInvalidBinding() throws Exception {
    final GremlinScriptEngine scriptEngine = manager.getEngineByName(ENGINE_TO_TEST);
    final Graph graph = EmptyGraph.instance();
    final GraphTraversalSource g = graph.traversal();

    // purposefully use "x" to match the name of the traversal source binding for "x" below and
    // thus tests the alias added for "x"
    final GraphTraversal t = getTraversalWithLambda(g);

    final Bindings bindings = new SimpleBindings();
    bindings.put("z", g);
    bindings.put("x", "invalid-binding-for-x-given-x-should-be-traversal-source");

    scriptEngine.eval(t.asAdmin().getBytecode(), bindings, "x");
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GremlinEnabledScriptEngineTest.java

示例4: shouldNotAllowBytecodeEvalWithAliasInBindings

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void shouldNotAllowBytecodeEvalWithAliasInBindings() throws Exception {
    final GremlinScriptEngine scriptEngine = manager.getEngineByName(ENGINE_TO_TEST);
    final Graph graph = EmptyGraph.instance();
    final GraphTraversalSource g = graph.traversal();

    // purposefully use "x" to match the name of the traversal source binding for "x" below and
    // thus tests the alias added for "x"
    final GraphTraversal t = getTraversalWithLambda(g);

    final Bindings bindings = new SimpleBindings();
    bindings.put("x", g);
    bindings.put(GremlinScriptEngine.HIDDEN_G, g);

    scriptEngine.eval(t.asAdmin().getBytecode(), bindings, "x");
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GremlinEnabledScriptEngineTest.java

示例5: shouldEvalBytecode

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldEvalBytecode() throws Exception {
    final GremlinScriptEngine scriptEngine = manager.getEngineByName(ENGINE_TO_TEST);
    final Graph graph = EmptyGraph.instance();
    final GraphTraversalSource g = graph.traversal();

    // purposefully use "x" to match the name of the traversal source binding for "x" below and
    // thus tests the alias added for "x"
    final GraphTraversal t = getTraversalWithLambda(g);

    final Bindings bindings = new SimpleBindings();
    bindings.put("x", g);

    final Traversal evald = scriptEngine.eval(t.asAdmin().getBytecode(), bindings, "x");

    assertTraversals(t, evald);

    assertThat(manager.getBindings().containsKey(GremlinScriptEngine.HIDDEN_G), is(false));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:20,代码来源:GremlinEnabledScriptEngineTest.java

示例6: formatTo

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
/**
 * Reveal the steps in the {@link SubTraversal} by passing a {@link DefaultGraphTraversal} to it,
 * and outputting it's string representation.
 */
@Override
@SneakyThrows
default void formatTo(Formatter formatter, int flags, int width, int precision) {
  GraphTraversalSource g = new GraphTraversalSource(EmptyGraph.instance());
  GraphTraversal<?, ?> graphTraversal = apply(g);
  formatter.out().append(graphTraversal.toString());
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:12,代码来源:AnyTraversal.java

示例7: main

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
/**
 * Run every example query, outputting results via @LOGGER
 *
 * @param argv
 * @throws Exception
 */
public static void main(String[] argv) throws Exception {
  Graph graph = EmptyGraph.instance();
  GraphTraversalSource graphTraversalSource = graph.traversal().withRemote(CONFIG_FILE);

  QueryRunner queryRunner = new QueryRunner(graphTraversalSource, "testUser0");

  LOGGER.info("Initialized the remote query executor");

  queryRunner.runQueries();

  queryRunner.close();
  // we don't need to close our graph because it is an empty graph.
}
 
开发者ID:marcelocf,项目名称:janusgraph_tutorial,代码行数:20,代码来源:RemoteQueries.java

示例8: shouldNotFindStepOfClassInTraversal

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldNotFindStepOfClassInTraversal() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    assertThat(TraversalHelper.hasStepOfClass(FilterStep.class, traversal), is(false));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:TraversalHelperTest.java

示例9: shouldFindStepOfClassInTraversal

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldFindStepOfClassInTraversal() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new IdentityStep<>(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    assertThat(TraversalHelper.hasStepOfClass(IdentityStep.class, traversal), is(true));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:TraversalHelperTest.java

示例10: shouldNotFindStepOfAssignableClassInTraversal

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldNotFindStepOfAssignableClassInTraversal() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    assertThat(TraversalHelper.hasStepOfAssignableClass(IdentityStep.class, traversal), is(false));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:TraversalHelperTest.java

示例11: shouldFindStepOfAssignableClassInTraversal

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldFindStepOfAssignableClassInTraversal() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    assertThat(TraversalHelper.hasStepOfAssignableClass(FilterStep.class, traversal), is(true));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:TraversalHelperTest.java

示例12: shouldGetTheStepIndex

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldGetTheStepIndex() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    final HasStep hasStep = new HasStep(traversal);
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, hasStep);
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    assertEquals(1, TraversalHelper.stepIndex(hasStep, traversal));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:TraversalHelperTest.java

示例13: shouldNotFindTheStepIndex

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldNotFindTheStepIndex() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    final IdentityStep identityStep = new IdentityStep(traversal);
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    assertEquals(-1, TraversalHelper.stepIndex(identityStep, traversal));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:TraversalHelperTest.java

示例14: shouldInsertBeforeStep

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldInsertBeforeStep() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    final HasStep hasStep = new HasStep(traversal);
    final IdentityStep identityStep = new IdentityStep(traversal);
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, hasStep);
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    TraversalHelper.insertBeforeStep(identityStep, hasStep, traversal);

    assertEquals(traversal.asAdmin().getSteps().get(1), identityStep);
    assertEquals(4, traversal.asAdmin().getSteps().size());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:TraversalHelperTest.java

示例15: shouldInsertAfterStep

import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; //导入方法依赖的package包/类
@Test
public void shouldInsertAfterStep() {
    final Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    final HasStep hasStep = new HasStep(traversal);
    final IdentityStep identityStep = new IdentityStep(traversal);
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, hasStep);
    traversal.asAdmin().addStep(0, new HasStep(traversal));

    TraversalHelper.insertAfterStep(identityStep, hasStep, traversal);

    assertEquals(traversal.asAdmin().getSteps().get(2), identityStep);
    assertEquals(4, traversal.asAdmin().getSteps().size());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:TraversalHelperTest.java


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