tinkerpop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmallette <...@git.apache.org>
Subject [GitHub] tinkerpop pull request #934: Apply StringEscapeUtils in GroovyTranslator#con...
Date Fri, 21 Sep 2018 19:37:50 GMT
Github user spmallette commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/934#discussion_r219606369
  
    --- Diff: gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
---
    @@ -141,4 +144,52 @@ public void shouldHandleEmptyMaps() {
         public void shouldHaveValidToString() {
             assertEquals("translator[h:gremlin-groovy]", GroovyTranslator.of("h").toString());
         }
    +
    +    @Test
    +    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
    +    public void shouldHandleTraversalAddV() {
    +        final GraphTraversalSource g = graph.traversal();
    +        final String script = GroovyTranslator.of("g").translate(g.addV("customer")
    +                .property("customer_id", 501L)
    +                .property("name", "Foo\u0020Bar")
    +                .property("salary", "\u0024\u00201000")
    +                .property("age", 25)
    +                .asAdmin().getBytecode());
    +
    +        assertEquals("g.addV(\"customer\")" +
    +                        ".property(\"customer_id\",501L)" +
    +                        ".property(\"name\",\"Foo\u0020Bar\")" +
    +                        ".property(\"salary\",\"\u005c\u005c\u0024\u00201000\")" +
    +                        ".property(\"age\",(int) 25)",
    +                script);
    +    }
    +
    +    @Test
    +    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
    +    public void shouldHandleVertex() {
    +        final GraphTraversalSource g = graph.traversal();
    +
    +        final String label1 = "customer";
    +        final Object id1 = "name:20:foo\u0020bar#50";
    +
    +        final Vertex vertex1 = DetachedVertex.build().setLabel(label1).setId(id1).create();
    +        final String script1 = GroovyTranslator.of("g").translate(g.V().inject(vertex1).asAdmin().getBytecode());
    +        assertEquals("g.V().inject(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(\"name:20:foo
bar#50\",\"customer\", Collections.emptyMap()))", script1);
    +
    +        final String label2 = "user";
    +        final Object id2 = "name:20:foo\\u0020bar#50";
    +
    +        final Vertex vertex2 = DetachedVertex.build().setLabel(label2).setId(id2).create();
    +        final String script2 = GroovyTranslator.of("g").translate(g.V().inject(vertex2).asAdmin().getBytecode());
    +        assertEquals("g.V().inject(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(\"name:20:foo\\\\u0020bar#50\",\"user\",
Collections.emptyMap()))", script2);
    +    }
    +
    +    @Test
    +    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
    +    public void shouldHandleLambda() {
    --- End diff --
    
    is this doing anything discernibly different than  `shouldSupportStringSupplierLambdas()`
test above? if there is a specific you are trying to assert here, perhaps it could be just
appended into that test?


---

Mime
View raw message