Search in sources :

Example 6 with CypherAstWrapper

use of org.opencypher.gremlin.translation.CypherAstWrapper in project cypher-for-gremlin by opencypher.

the class Translation method translateVerbose.

@Test
public void translateVerbose() throws Exception {
    // freshReadmeSnippet: verbose
    String cypher = "MATCH (p:Person) WHERE p.age > 25 RETURN p.name";
    CypherAstWrapper ast = CypherAstWrapper.parse(cypher);
    Translator<String, GroovyPredicate> translator = Translator.builder().gremlinGroovy().build();
    String gremlin = ast.buildTranslation(translator);
    // freshReadmeSnippet: verbose
    assertThat(gremlin).startsWith("g.V()");
}
Also used : GroovyPredicate(org.opencypher.gremlin.translation.groovy.GroovyPredicate) CypherAstWrapper(org.opencypher.gremlin.translation.CypherAstWrapper) Test(org.junit.Test)

Example 7 with CypherAstWrapper

use of org.opencypher.gremlin.translation.CypherAstWrapper in project cypher-for-gremlin by opencypher.

the class NoCustomFunctionsTest method functionsAndPredicates.

@Test
public void functionsAndPredicates() {
    String cypher = "MATCH (n:N) " + "WITH n.p AS s " + "WHERE s STARTS WITH 'x' " + "AND s ENDS WITH 'x' " + "AND s CONTAINS 'x' " + "RETURN length(s), toString(s)";
    CypherAstWrapper ast = CypherAstWrapper.parse(cypher);
    Translator<String, GroovyPredicate> translator = Translator.builder().gremlinGroovy().build(flavor);
    assertThatThrownBy(() -> ast.buildTranslation(translator)).hasMessageContaining("contains, convertToString, endsWith, length, starsWith");
}
Also used : GroovyPredicate(org.opencypher.gremlin.translation.groovy.GroovyPredicate) CypherAstWrapper(org.opencypher.gremlin.translation.CypherAstWrapper) Test(org.junit.Test)

Aggregations

CypherAstWrapper (org.opencypher.gremlin.translation.CypherAstWrapper)7 P (org.apache.tinkerpop.gremlin.process.traversal.P)4 GroovyPredicate (org.opencypher.gremlin.translation.groovy.GroovyPredicate)4 ReturnNormalizer (org.opencypher.gremlin.traversal.ReturnNormalizer)4 DefaultGraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal)3 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)3 ResultSet (org.apache.tinkerpop.gremlin.driver.ResultSet)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Result (org.apache.tinkerpop.gremlin.driver.Result)1 Bytecode (org.apache.tinkerpop.gremlin.process.traversal.Bytecode)1 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)1