mattyb149 commented on a change in pull request #4204: NIFI-7355 Added Gremlin 
bytecode client service.
URL: https://github.com/apache/nifi/pull/4204#discussion_r409675718
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/groovy/org/apache/nifi/graph/GremlinBytecodeClientServiceIT.groovy
 ##########
 @@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.graph
+
+import org.apache.nifi.processor.AbstractProcessor
+import org.apache.nifi.processor.ProcessContext
+import org.apache.nifi.processor.ProcessSession
+import org.apache.nifi.processor.exception.ProcessException
+import org.apache.nifi.util.TestRunner
+import org.apache.nifi.util.TestRunners
+import org.junit.Before
+import org.junit.Test
+
+class GremlinBytecodeClientServiceIT {
+    TestRunner runner
+    GraphClientService service
+
+    @Before
+    void before() {
+        runner = TestRunners.newTestRunner(new AbstractProcessor() {
+            @Override
+            void onTrigger(ProcessContext processContext, ProcessSession 
processSession) throws ProcessException {
+
+            }
+        })
+
+        service = new GremlinBytecodeClientService()
+        runner.addControllerService("service", service);
+        runner.setProperty(service, 
GremlinBytecodeClientService.CONTACT_POINTS, "localhost")
+        runner.setProperty(service, GremlinBytecodeClientService.PORT, "8182")
+        runner.setProperty(service, GremlinBytecodeClientService.PATH, 
"/gremlin")
+        runner.enableControllerService(service)
+        runner.assertValid()
+    }
+
+    @Test
+    void testQuery() {
+        def query = """
+            assert param
+            g.V().hasLabel("nada").count().next()
+        """
+
+        service.executeQuery(query, [ param: "Hi!" ], { result, more ->
+            assert result
+            assert result["result"] == 0
+        } as GraphQueryResultCallback)
+    }
+
+    @Test
+    void testMassGenerate() {
+        def query = """
+            assert param
+            1.upto(100) {
+                def trav = g.addV("it_test_node")
+                2.upto(250) {
+                    trav.addV("it_test_node").property("uuid", 
UUID.randomUUID().toString())
+                }
+                trav.next()
+            }
+            def count = g.V().hasLabel("it_test_node").count().next()
+            g.V().hasLabel("it_test_node").drop().iterate()
+            count
+        """.trim()
+
+        service.executeQuery(query, [ param: "Hi!" ], { result, more ->
 
 Review comment:
   I don't see the param value being used anywhere except the assert. Would it 
be good to add an example where you use the param as a property on the vertices 
and then test for its presence? Or am I misunderstanding how param should be 
used?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to