javeme commented on code in PR #539: URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/539#discussion_r1410154084
########## hugegraph-client/src/test/java/org/apache/hugegraph/api/traverser/EdgeExistenceAPITest.java: ########## @@ -0,0 +1,68 @@ +/* + * 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.hugegraph.api.traverser; + + +import org.apache.hugegraph.api.BaseApiTest; +import org.apache.hugegraph.structure.graph.Edge; +import org.apache.hugegraph.testutil.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.List; + +public class EdgeExistenceAPITest extends TraverserApiTest{ + + @BeforeClass + public static void prepareSchemaAndGraph() { + BaseApiTest.initPropertyKey(); + BaseApiTest.initVertexLabel(); + BaseApiTest.initEdgeLabel(); + BaseApiTest.initIndexLabel(); + BaseApiTest.initVertex(); + BaseApiTest.initEdge(); + } + + @Test + public void testEdgeExistenceGet() { + Object markoId = getVertexId("person", "name", "marko"); + Object vadasId = getVertexId("person", "name", "vadas"); + + List<Edge> edges = edgeExistenceAPI.get(markoId, vadasId, + "knows", "", 100); + + Assert.assertEquals(1, edges.size()); + String id = edges.get(0).id(); + + Assert.assertTrue(id.contains("marko")); + Assert.assertTrue(id.contains("vadas")); + + Object lopId = getVertexId("software", "name", "lop"); + + edges = edgeExistenceAPI.get(lopId, vadasId, + "knows", "", 100); Review Comment: seems one line is ok ########## hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java: ########## @@ -538,4 +541,10 @@ public Iterator<Edge> iteratorEdges(Shard shard, int sizePerPage) { return this.edges(shard, page, sizePerPage); }); } + + public List<Edge> edgeExistence(Object sourceId, Object targetId, String edgeLabel, Review Comment: also add this 2 versions: ```java edgeExistence(Object sourceId, Object targetId) edgeExistence(Object sourceId, Object targetId, String edgeLabel) ``` ########## hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java: ########## @@ -538,4 +541,10 @@ public Iterator<Edge> iteratorEdges(Shard shard, int sizePerPage) { return this.edges(shard, page, sizePerPage); }); } + + public List<Edge> edgeExistence(Object sourceId, Object targetId, String edgeLabel, + String sortValues, long limit){ + return this.edgeExistenceAPI.get(sourceId, targetId, edgeLabel, + sortValues, limit); Review Comment: seems one line is ok ########## hugegraph-client/src/test/java/org/apache/hugegraph/api/traverser/EdgeExistenceAPITest.java: ########## @@ -0,0 +1,68 @@ +/* + * 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.hugegraph.api.traverser; + + +import org.apache.hugegraph.api.BaseApiTest; +import org.apache.hugegraph.structure.graph.Edge; +import org.apache.hugegraph.testutil.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.List; + +public class EdgeExistenceAPITest extends TraverserApiTest{ + + @BeforeClass + public static void prepareSchemaAndGraph() { + BaseApiTest.initPropertyKey(); + BaseApiTest.initVertexLabel(); + BaseApiTest.initEdgeLabel(); + BaseApiTest.initIndexLabel(); + BaseApiTest.initVertex(); + BaseApiTest.initEdge(); + } + + @Test + public void testEdgeExistenceGet() { + Object markoId = getVertexId("person", "name", "marko"); + Object vadasId = getVertexId("person", "name", "vadas"); + + List<Edge> edges = edgeExistenceAPI.get(markoId, vadasId, + "knows", "", 100); + + Assert.assertEquals(1, edges.size()); + String id = edges.get(0).id(); + + Assert.assertTrue(id.contains("marko")); + Assert.assertTrue(id.contains("vadas")); + + Object lopId = getVertexId("software", "name", "lop"); + + edges = edgeExistenceAPI.get(lopId, vadasId, + "knows", "", 100); + Assert.assertEquals(0, edges.size()); + + Object joshId = getVertexId("person", "name", "josh"); + Object rippleId = getVertexId("person", "name", "ripple"); + + edges = edgeExistenceAPI.get(joshId, rippleId, + "created", "", 100); Review Comment: seems one line is ok ########## hugegraph-client/src/main/java/org/apache/hugegraph/driver/TraverserManager.java: ########## @@ -538,4 +541,10 @@ public Iterator<Edge> iteratorEdges(Shard shard, int sizePerPage) { return this.edges(shard, page, sizePerPage); }); } + + public List<Edge> edgeExistence(Object sourceId, Object targetId, String edgeLabel, + String sortValues, long limit){ Review Comment: expect `int limit` -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
