Java Code Examples for org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph#instance()
The following examples show how to use
org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph#instance() .
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: EventStrategyTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@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()); }
Example 2
Source File: GremlinEnabledScriptEngineTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@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"); }
Example 3
Source File: GremlinEnabledScriptEngineTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@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"); }
Example 4
Source File: GremlinEnabledScriptEngineTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@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)); }
Example 5
Source File: GremlinEnabledScriptEngineTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowBytecodeEvalWithMissingBinding() 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); scriptEngine.eval(t.asAdmin().getBytecode(), bindings, "x"); }
Example 6
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldAddStepsCorrectly() { Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance()); traversal.asAdmin().addStep(0, new LambdaFilterStep(traversal, traverser -> true)); traversal.asAdmin().addStep(0, new HasStep(traversal)); traversal.asAdmin().addStep(0, new IdentityStep(traversal)); validateToyTraversal(traversal); traversal = new DefaultTraversal<>(EmptyGraph.instance()); traversal.asAdmin().addStep(0, new IdentityStep(traversal)); traversal.asAdmin().addStep(1, new HasStep(traversal)); traversal.asAdmin().addStep(2, new LambdaFilterStep(traversal, traverser -> true)); validateToyTraversal(traversal); }
Example 7
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldChainTogetherStepsWithNextPreviousInALinkedListStructure() { 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)); validateToyTraversal(traversal); }
Example 8
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@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()); }
Example 9
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@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()); }
Example 10
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@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)); }
Example 11
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@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)); }
Example 12
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@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)); }
Example 13
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@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)); }
Example 14
Source File: TraversalHelperTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@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)); }
Example 15
Source File: GremlinEnabledScriptEngineTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowBytecodeEvalWithAliasAsTraversalSource() 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); scriptEngine.eval(t.asAdmin().getBytecode(), bindings, GremlinScriptEngine.HIDDEN_G); }
Example 16
Source File: RemoteQueries.java From janusgraph_tutorial with Apache License 2.0 | 5 votes |
/** * 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. }
Example 17
Source File: DefaultTraversal.java From tinkerpop with Apache License 2.0 | 4 votes |
public DefaultTraversal(final Bytecode bytecode) { this(EmptyGraph.instance(), TraversalStrategies.GlobalCache.getStrategies(EmptyGraph.class), bytecode); }
Example 18
Source File: GraphTraversalSource.java From tinkerpop with Apache License 2.0 | 4 votes |
public GraphTraversalSource(final RemoteConnection connection) { this(EmptyGraph.instance(), TraversalStrategies.GlobalCache.getStrategies(EmptyGraph.class).clone()); this.connection = connection; this.strategies.addStrategies(new RemoteStrategy(connection)); }
Example 19
Source File: ReferenceElement.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Graph graph() { return EmptyGraph.instance(); }
Example 20
Source File: DetachedElement.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Graph graph() { return EmptyGraph.instance(); }