This is an automated email from the ASF dual-hosted git repository.
ming pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-hugegraph-toolchain.git
The following commit(s) were added to refs/heads/master by this push:
new cb68beac feat: update common version and remove jersey code (#538)
cb68beac is described below
commit cb68beac76b9d0492054bade87cdfccbb3ae15bf
Author: 小宇 <[email protected]>
AuthorDate: Tue Dec 5 15:10:52 2023 +0800
feat: update common version and remove jersey code (#538)
* Update client-ci.yml
add on workflow_dispatch
* replace jersey with okhttp
* fix test error
* fix the problem that mockito can't mock final class
* fix error
* Update BaseClientTest.java
* https support && add licence header
* fix licence check error
* fix error
* fix licence check error
* fix error
* rename rest class && remove jersey dependency
* add workflow_dispatch
* add workflow_dispatch
* hubble error fix
* update okhttp version of hubble
* refactor class name
* add workflow_dispatch
* fix licence dependency check error
* feat: merge request
* chore(ci): add stage profile settings
* update common version and fix code
* fix
* fix
* update version
* fix spark-connector-ci
* fix spark-connector-ci
* fix spark-connector-ci
* update client version
* update client version
* fix license-checker
* code optimize
* remove useless dependency
* remove useless code
* fix licence check
* fix import & update api version
* remove redundant common import in hubble
* remove redundant lombok version
* remove useless code
* add comment
* rename id
* add encode test case
* add encode test case and fix code issue
* fix test error
* fix test error
* fix code issue
* fix code issue
* fix code issue
* update hg server commitId
* debug ci error
* revert commit ID & let it pass 100
* Update client-ci.yml
* tiny fix
---------
Co-authored-by: tianzy <[email protected]>
Co-authored-by: imbajin <[email protected]>
---
.github/workflows/client-ci.yml | 5 +-
.github/workflows/codeql-analysis.yml | 3 +
.github/workflows/hubble-ci.yml | 6 +-
.github/workflows/loader-ci.yml | 5 +-
.github/workflows/tools-ci.yml | 4 +-
.licenserc.yaml | 1 +
.../travis/install-hugegraph-from-source.sh | 2 +-
hugegraph-client/pom.xml | 19 +-
.../org/apache/hugegraph/api/auth/UserAPI.java | 4 +-
.../org/apache/hugegraph/api/graph/EdgeAPI.java | 26 +--
.../org/apache/hugegraph/api/graph/GraphAPI.java | 18 +-
.../org/apache/hugegraph/api/graph/VertexAPI.java | 21 +--
.../org/apache/hugegraph/api/graphs/GraphsAPI.java | 27 +--
.../org/apache/hugegraph/client/RestClient.java | 17 +-
.../org/apache/hugegraph/driver/HugeClient.java | 14 +-
.../hugegraph/exception/ServerException.java | 12 +-
.../java/org/apache/hugegraph/BaseClientTest.java | 47 ++---
.../org/apache/hugegraph/api/SchemaApiTest.java | 2 +-
.../org/apache/hugegraph/api/auth/UserApiTest.java | 24 ++-
.../org/apache/hugegraph/functional/EdgeTest.java | 174 +++++++++---------
.../apache/hugegraph/functional/SchemaTest.java | 2 +-
.../org/apache/hugegraph/unit/RestResultTest.java | 204 +++++++++++----------
.../org.mockito.plugins.MockMaker | 17 ++
.../scripts/dependency/known-dependencies.txt | 34 ++--
hugegraph-hubble/hubble-be/pom.xml | 69 +++++--
.../assembly/travis/download-hugegraph.sh | 20 +-
hugegraph-hubble/pom.xml | 9 +-
hugegraph-loader/pom.xml | 7 +-
hugegraph-spark-connector/pom.xml | 34 +---
pom.xml | 15 +-
30 files changed, 410 insertions(+), 432 deletions(-)
diff --git a/.github/workflows/client-ci.yml b/.github/workflows/client-ci.yml
index f1448f80..b8c19c70 100644
--- a/.github/workflows/client-ci.yml
+++ b/.github/workflows/client-ci.yml
@@ -1,6 +1,7 @@
name: "hugegraph-client-ci"
on:
+ workflow_dispatch:
push:
branches:
- master
@@ -23,11 +24,12 @@ jobs:
env:
USE_STAGE: 'true' # Whether to include the stage repository.
TRAVIS_DIR: hugegraph-client/assembly/travis
+ # TODO: replace it with the (latest - n) commit id (n >= 15)
COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314
strategy:
fail-fast: false
matrix:
- JAVA_VERSION: ['8']
+ JAVA_VERSION: [ '8' ]
steps:
- name: Install JDK 8
uses: actions/setup-java@v3
@@ -71,4 +73,5 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
+ token: ${{ secrets.CODECOV_TOKEN }}
file: target/jacoco.xml
diff --git a/.github/workflows/codeql-analysis.yml
b/.github/workflows/codeql-analysis.yml
index 838b4c5f..9ee5a653 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -12,6 +12,9 @@
name: "CodeQL"
on:
+ workflow_dispatch:
+ push:
+ branches: [ master, release-* ]
pull_request:
# The branches below must be a subset of the branches above
# branches: [ master ] # enable in all PR
diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml
index c07078c1..ea186d40 100644
--- a/.github/workflows/hubble-ci.yml
+++ b/.github/workflows/hubble-ci.yml
@@ -1,6 +1,7 @@
name: "hugegraph-hubble-ci"
on:
+ workflow_dispatch:
push:
branches:
- master
@@ -22,7 +23,7 @@ on:
env:
TRAVIS_DIR: hugegraph-hubble/hubble-dist/assembly/travis
- # TODO: need update it later (eed6103359fe40d2f1476fb8c56d9388c3111a99)
+ # TODO: replace it with the (latest - n) commit id (n >= 15)
COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314
jobs:
@@ -113,6 +114,7 @@ jobs:
hubble-dist/assembly/travis/run-api-test.sh
- name: Upload coverage to Codecov
- uses: codecov/[email protected]
+ uses: codecov/codecov-action@v3
with:
+ token: ${{ secrets.CODECOV_TOKEN }}
file: target/site/jacoco/*.xml
diff --git a/.github/workflows/loader-ci.yml b/.github/workflows/loader-ci.yml
index d3132a31..3c676302 100644
--- a/.github/workflows/loader-ci.yml
+++ b/.github/workflows/loader-ci.yml
@@ -1,6 +1,7 @@
name: "hugegraph-loader-ci"
on:
+ workflow_dispatch:
push:
branches:
- master
@@ -25,6 +26,7 @@ jobs:
USE_STAGE: 'true' # Whether to include the stage repository.
TRAVIS_DIR: hugegraph-loader/assembly/travis
STATIC_DIR: hugegraph-loader/assembly/static
+ # TODO: replace it with the (latest - n) commit id (n >= 15)
COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314
DB_USER: root
DB_PASS: root
@@ -74,6 +76,7 @@ jobs:
mvn test -P kafka
- name: Upload coverage to Codecov
- uses: codecov/[email protected]
+ uses: codecov/codecov-action@v3
with:
+ token: ${{ secrets.CODECOV_TOKEN }}
file: target/jacoco.xml
diff --git a/.github/workflows/tools-ci.yml b/.github/workflows/tools-ci.yml
index f0e66625..f00582b2 100644
--- a/.github/workflows/tools-ci.yml
+++ b/.github/workflows/tools-ci.yml
@@ -1,5 +1,6 @@
name: "hugegraph-tools-ci"
on:
+ workflow_dispatch:
push:
branches:
- master
@@ -56,6 +57,7 @@ jobs:
run: |
mvn test -Dtest=FuncTestSuite -pl hugegraph-tools -ntp
- name: Upload coverage to Codecov
- uses: codecov/[email protected]
+ uses: codecov/codecov-action@v3
with:
+ token: ${{ secrets.CODECOV_TOKEN }}
file: target/jacoco.xml
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 789856df..827be9c8 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -75,6 +75,7 @@ header: # `header` section is configurations for source codes
license header.
- 'assembly/**'
- '.github/**/*'
- '**/target/*'
+ -
'hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker'
# - 'hugegraph-hubble/hubble-fe/**'
comment: on-failure # on what condition license-eye will comment on the pull
request, `on-failure`, `always`, `never`.
diff --git a/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh
b/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh
index df912fb0..2c9ea319 100755
--- a/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh
+++ b/hugegraph-client/assembly/travis/install-hugegraph-from-source.sh
@@ -60,5 +60,5 @@ echo "gremlinserver.url=http://127.0.0.1:8282" >>
${REST_SERVER_CONFIG}
# start HugeGraphServer with https protocol
bin/init-store.sh
-bin/start-hugegraph.sh
+bin/start-hugegraph.sh || (cat logs/hugegraph-server.log && exit 1)
cd ../
diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml
index ec867df2..08b8d3eb 100644
--- a/hugegraph-client/pom.xml
+++ b/hugegraph-client/pom.xml
@@ -15,8 +15,8 @@
License for the specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -30,15 +30,12 @@
<packaging>jar</packaging>
<name>${project.artifactId}</name>
-
<url>https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-client</url>
+
<url>https://github.com/apache/hugegraph-toolchain/tree/master/hugegraph-client</url>
<description>
hugegraph-client is a Java-written client of HugeGraph, providing
operations of graph, schema, gremlin, variables and traversals etc.
</description>
- <properties>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.hugegraph</groupId>
@@ -48,15 +45,17 @@
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
</dependency>
- <dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet</artifactId>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <optional>true</optional>
+ </dependency>
</dependencies>
<build>
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java
index 30fbb9ed..3c1c1d0c 100644
--- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java
+++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java
@@ -50,8 +50,8 @@ public class UserAPI extends AuthAPI {
}
public UserRole getUserRole(Object id) {
- String idEncoded = RestClient.encode(formatEntityId(id));
- String path = String.join("/", this.path(), idEncoded, "role");
+ String formattedId = formatEntityId(id);
+ String path = String.join("/", this.path(), formattedId, "role");
RestResult result = this.client.get(path);
return result.readObject(UserRole.class);
}
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java
index f55f1704..36c3eb19 100644
--- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java
+++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java
@@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.exception.NotAllCreatedException;
+import org.apache.hugegraph.rest.RestHeaders;
import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.structure.constant.Direction;
import org.apache.hugegraph.structure.constant.HugeType;
@@ -32,8 +33,6 @@ import org.apache.hugegraph.structure.graph.Edges;
import com.google.common.collect.ImmutableMap;
-import jakarta.ws.rs.core.MultivaluedHashMap;
-
public class EdgeAPI extends GraphAPI {
public EdgeAPI(RestClient client, String graph) {
@@ -51,12 +50,9 @@ public class EdgeAPI extends GraphAPI {
}
public List<String> create(List<Edge> edges, boolean checkVertex) {
- MultivaluedHashMap<String, Object> headers = new
MultivaluedHashMap<>();
- headers.putSingle("Content-Encoding", BATCH_ENCODING);
- Map<String, Object> params = ImmutableMap.of("check_vertex",
- checkVertex);
- RestResult result = this.client.post(this.batchPath(), edges,
- headers, params);
+ RestHeaders headers = new
RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING);
+ Map<String, Object> params = ImmutableMap.of("check_vertex",
checkVertex);
+ RestResult result = this.client.post(this.batchPath(), edges, headers,
params);
List<String> ids = result.readList(String.class);
if (edges.size() != ids.size()) {
throw new NotAllCreatedException("Not all edges are successfully
created, " +
@@ -68,10 +64,8 @@ public class EdgeAPI extends GraphAPI {
public List<Edge> update(BatchEdgeRequest request) {
this.client.checkApiVersion("0.45", "batch property update");
- MultivaluedHashMap<String, Object> headers = new
MultivaluedHashMap<>();
- headers.putSingle("Content-Encoding", BATCH_ENCODING);
- RestResult result = this.client.put(this.batchPath(), null,
- request, headers);
+ RestHeaders headers = new
RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING);
+ RestResult result = this.client.put(this.batchPath(), null, request,
headers);
return result.readList(this.type(), Edge.class);
}
@@ -98,11 +92,9 @@ public class EdgeAPI extends GraphAPI {
return this.list(null, null, null, null, 0, null, limit);
}
- public Edges list(Object vertexId, Direction direction,
- String label, Map<String, Object> properties,
- int offset, String page, int limit) {
- return this.list(vertexId, direction, label, properties, false,
- offset, page, limit);
+ public Edges list(Object vertexId, Direction direction, String label,
+ Map<String, Object> properties, int offset, String page,
int limit) {
+ return this.list(vertexId, direction, label, properties, false,
offset, page, limit);
}
public Edges list(Object vertexId, Direction direction, String label,
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java
index edea0d6c..c2eb7681 100644
---
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java
+++
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/GraphAPI.java
@@ -20,9 +20,6 @@ package org.apache.hugegraph.api.graph;
import java.util.Map;
import java.util.UUID;
-import org.glassfish.jersey.uri.UriComponent;
-import org.glassfish.jersey.uri.UriComponent.Type;
-
import org.apache.hugegraph.api.API;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.util.E;
@@ -61,8 +58,7 @@ public abstract class GraphAPI extends API {
id = id.toString();
}
E.checkArgument(id instanceof String || id instanceof Number,
- "The vertex id must be either String or " +
- "Number, but got '%s'", id);
+ "The vertex id must be either String or Number, but
got '%s'", id);
return (uuid ? "U" : "") + JsonUtil.toJson(id);
}
@@ -70,16 +66,6 @@ public abstract class GraphAPI extends API {
if (properties == null) {
return null;
}
- String json = JsonUtil.toJson(properties);
- /*
- * Don't use UrlEncoder.encode, it encoded the space as `+`,
- * which will invalidate the jersey's automatic decoding
- * because it considers the space to be encoded as `%2F`
- */
- return encode(json);
- }
-
- public static String encode(String raw) {
- return UriComponent.encode(raw, Type.QUERY_PARAM_SPACE_ENCODED);
+ return JsonUtil.toJson(properties);
}
}
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java
index 6f283683..70f4de78 100644
---
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java
+++
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java
@@ -24,6 +24,8 @@ import java.util.Map;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.exception.InvalidResponseException;
import org.apache.hugegraph.exception.NotAllCreatedException;
+import org.apache.hugegraph.rest.RestHeaders;
+import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.structure.constant.HugeType;
import org.apache.hugegraph.structure.graph.BatchOlapPropertyRequest;
import org.apache.hugegraph.structure.graph.BatchVertexRequest;
@@ -32,10 +34,6 @@ import org.apache.hugegraph.structure.graph.Vertices;
import com.google.common.collect.ImmutableMap;
-import jakarta.ws.rs.core.MultivaluedHashMap;
-
-import org.apache.hugegraph.rest.RestResult;
-
public class VertexAPI extends GraphAPI {
public VertexAPI(RestClient client, String graph) {
@@ -53,10 +51,8 @@ public class VertexAPI extends GraphAPI {
}
public List<Object> create(List<Vertex> vertices) {
- MultivaluedHashMap<String, Object> headers = new
MultivaluedHashMap<>();
- headers.putSingle("Content-Encoding", BATCH_ENCODING);
- RestResult result = this.client.post(this.batchPath(), vertices,
- headers);
+ RestHeaders headers = new
RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING);
+ RestResult result = this.client.post(this.batchPath(), vertices,
headers);
List<Object> ids = result.readList(Object.class);
if (vertices.size() != ids.size()) {
throw new NotAllCreatedException("Not all vertices are
successfully created, " +
@@ -68,17 +64,14 @@ public class VertexAPI extends GraphAPI {
public List<Vertex> update(BatchVertexRequest request) {
this.client.checkApiVersion("0.45", "batch property update");
- MultivaluedHashMap<String, Object> headers = new
MultivaluedHashMap<>();
- headers.putSingle("Content-Encoding", BATCH_ENCODING);
- RestResult result = this.client.put(this.batchPath(), null,
- request, headers);
+ RestHeaders headers = new
RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING);
+ RestResult result = this.client.put(this.batchPath(), null, request,
headers);
return result.readList(this.type(), Vertex.class);
}
public int update(BatchOlapPropertyRequest request) {
this.client.checkApiVersion("0.59", "olap property batch update");
- MultivaluedHashMap<String, Object> headers = new
MultivaluedHashMap<>();
- headers.putSingle("Content-Encoding", BATCH_ENCODING);
+ RestHeaders headers = new
RestHeaders().add(RestHeaders.CONTENT_ENCODING, BATCH_ENCODING);
String path = String.join("/", this.path(), "olap/batch");
RestResult result = this.client.put(path, null, request, headers);
Object size = result.readObject(Map.class).get("size");
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java
index 16101b7e..8310e44f 100644
---
a/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java
+++
b/hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java
@@ -20,15 +20,11 @@ package org.apache.hugegraph.api.graphs;
import java.util.List;
import java.util.Map;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.MultivaluedHashMap;
-
import org.apache.commons.lang3.StringUtils;
-
import org.apache.hugegraph.api.API;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.exception.InvalidResponseException;
+import org.apache.hugegraph.rest.RestHeaders;
import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.structure.constant.GraphMode;
import org.apache.hugegraph.structure.constant.GraphReadMode;
@@ -42,7 +38,6 @@ public class GraphsAPI extends API {
private static final String MODE = "mode";
private static final String GRAPH_READ_MODE = "graph_read_mode";
private static final String CLEAR = "clear";
-
private static final String CONFIRM_MESSAGE = "confirm_message";
public GraphsAPI(RestClient client) {
@@ -56,11 +51,9 @@ public class GraphsAPI extends API {
}
@SuppressWarnings("unchecked")
- public Map<String, String> create(String name, String cloneGraphName,
- String configText) {
+ public Map<String, String> create(String name, String cloneGraphName,
String configText) {
this.client.checkApiVersion("0.67", "dynamic graph add");
- MultivaluedHashMap<String, Object> headers = new
MultivaluedHashMap<>();
- headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN);
+ RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_TYPE,
"text/plain");
Map<String, Object> params = null;
if (StringUtils.isNotEmpty(cloneGraphName)) {
params = ImmutableMap.of("clone_graph_name", cloneGraphName);
@@ -93,8 +86,8 @@ public class GraphsAPI extends API {
}
public void mode(String graph, GraphMode mode) {
- // NOTE: Must provide id for PUT. If use "graph/mode", "/" will
- // be encoded to "%2F". So use "mode" here although inaccurate.
+ // NOTE: Must provide id for PUT. If you use "graph/mode", "/" will
+ // be encoded to "%2F". So use "mode" here, although inaccurate.
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
}
@@ -115,17 +108,15 @@ public class GraphsAPI extends API {
public void readMode(String graph, GraphReadMode readMode) {
this.client.checkApiVersion("0.59", "graph read mode");
- // NOTE: Must provide id for PUT. If use "graph/graph_read_mode", "/"
- // will be encoded to "%2F". So use "graph_read_mode" here although
+ // NOTE: Must provide id for PUT. If you use "graph/graph_read_mode",
"/"
+ // will be encoded to "%2F". So use "graph_read_mode" here, although
// inaccurate.
- this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE),
- null, readMode);
+ this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null,
readMode);
}
public GraphReadMode readMode(String graph) {
this.client.checkApiVersion("0.59", "graph read mode");
- RestResult result = this.client.get(joinPath(this.path(), graph),
- GRAPH_READ_MODE);
+ RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
@SuppressWarnings("unchecked")
Map<String, String> readMode = result.readObject(Map.class);
String value = readMode.get(GRAPH_READ_MODE);
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java
index 22650816..a63e1f33 100644
--- a/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java
+++ b/hugegraph-client/src/main/java/org/apache/hugegraph/client/RestClient.java
@@ -18,18 +18,17 @@
package org.apache.hugegraph.client;
import org.apache.hugegraph.exception.ServerException;
-import org.apache.hugegraph.serializer.PathDeserializer;
-import org.apache.hugegraph.structure.graph.Path;
import org.apache.hugegraph.rest.AbstractRestClient;
import org.apache.hugegraph.rest.ClientException;
import org.apache.hugegraph.rest.RestResult;
+import org.apache.hugegraph.serializer.PathDeserializer;
+import org.apache.hugegraph.structure.graph.Path;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.VersionUtil;
import org.apache.hugegraph.util.VersionUtil.Version;
import com.fasterxml.jackson.databind.module.SimpleModule;
-import jakarta.ws.rs.core.Response;
public class RestClient extends AbstractRestClient {
@@ -43,8 +42,7 @@ public class RestClient extends AbstractRestClient {
RestResult.registerModule(module);
}
- public RestClient(String url, String username, String password,
- int timeout) {
+ public RestClient(String url, String username, String password, int
timeout) {
super(url, username, password, timeout * SECOND);
}
@@ -73,16 +71,15 @@ public class RestClient extends AbstractRestClient {
}
public boolean apiVersionLt(String minVersion) {
- String apiVersion = this.apiVersion == null ?
- null : this.apiVersion.get();
+ String apiVersion = this.apiVersion == null ? null :
this.apiVersion.get();
return apiVersion != null && !VersionUtil.gte(apiVersion, minVersion);
}
@Override
- protected void checkStatus(Response response, Response.Status... statuses)
{
+ protected void checkStatus(okhttp3.Response response, int... statuses) {
boolean match = false;
- for (Response.Status status : statuses) {
- if (status.getStatusCode() == response.getStatus()) {
+ for (int status : statuses) {
+ if (status == response.code()) {
match = true;
break;
}
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java
index caa48586..56acc337 100644
--- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java
+++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java
@@ -19,16 +19,17 @@ package org.apache.hugegraph.driver;
import java.io.Closeable;
-import org.apache.hugegraph.version.ClientVersion;
import org.apache.hugegraph.client.RestClient;
-
import org.apache.hugegraph.rest.ClientException;
import org.apache.hugegraph.util.VersionUtil;
-
-import jakarta.ws.rs.ProcessingException;
+import org.apache.hugegraph.version.ClientVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HugeClient implements Closeable {
+ private static final Logger LOG =
LoggerFactory.getLogger(RestClient.class);
+
static {
ClientVersion.check();
}
@@ -60,7 +61,8 @@ public class HugeClient implements Closeable {
builder.maxConnsPerRoute(),
builder.trustStoreFile(),
builder.trustStorePassword());
- } catch (ProcessingException e) {
+ } catch (Exception e) {
+ LOG.warn("Failed to create RestClient instance", e);
throw new ClientException("Failed to connect url '%s'",
builder.url());
}
try {
@@ -110,7 +112,7 @@ public class HugeClient implements Closeable {
private void checkServerApiVersion() {
VersionUtil.Version apiVersion =
VersionUtil.Version.of(this.version.getApiVersion());
// TODO: find a way to keep the range of api version correct
automatically
- // 0.81 equals to the {latest_api_version} +10
+ // 0.81 equals to the {latest_api_version} +10
VersionUtil.check(apiVersion, "0.38", "0.81", "hugegraph-api in
server");
this.client.apiVersion(apiVersion);
}
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java
index e718181d..aa982632 100644
---
a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java
+++
b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java
@@ -23,31 +23,27 @@ import org.apache.hugegraph.rest.RestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import jakarta.ws.rs.core.Response;
-
public class ServerException extends RuntimeException {
private static final Logger LOG =
LoggerFactory.getLogger(ServerException.class);
private static final long serialVersionUID = 6335623004322652358L;
- private static final String[] EXCEPTION_KEYS = {"exception",
- "Exception-Class"};
+ private static final String[] EXCEPTION_KEYS = {"exception",
"Exception-Class"};
private static final String[] MESSAGE_KEYS = {"message"};
private static final String[] CAUSE_KEYS = {"cause", "exceptions"};
private static final String[] TRACE_KEYS = {"trace", "stackTrace"};
-
private int status = 0;
private String exception;
private String message;
private String cause;
private Object trace;
- public static ServerException fromResponse(Response response) {
+ public static ServerException fromResponse(okhttp3.Response response) {
RestResult rs = new RestResult(response);
ServerException exception = new ServerException(rs.content());
- exception.status(response.getStatus());
+ exception.status(response.code());
try {
@SuppressWarnings("unchecked")
Map<String, Object> json = rs.readObject(Map.class);
@@ -56,7 +52,7 @@ public class ServerException extends RuntimeException {
exception.cause = (String) getByKeys(json, CAUSE_KEYS);
exception.trace = getByKeys(json, TRACE_KEYS);
} catch (Exception ignored) {
- LOG.error("ServerException fromResponse excepiton");
+ LOG.error("ServerException fromResponse exception");
}
return exception;
diff --git
a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java
b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java
index e195d12e..471f135d 100644
--- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java
+++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java
@@ -57,11 +57,8 @@ public class BaseClientTest {
private static HugeClient client;
- protected static HugeClient open() {
- client = HugeClient.builder(BASE_URL, GRAPH)
- .configUser(USERNAME, PASSWORD)
- .build();
- return client;
+ protected static void open() {
+ client = HugeClient.builder(BASE_URL, GRAPH).configUser(USERNAME,
PASSWORD).build();
}
@BeforeClass
@@ -125,18 +122,7 @@ public class BaseClientTest {
return client.metrics();
}
- @Before
- public void setup() {
- // this.clearData();
- }
-
- @After
- public void teardown() throws Exception {
- // pass
- }
-
- protected static Object getVertexId(String label, String key,
- String value) {
+ protected static Object getVertexId(String label, String key, String
value) {
return getVertex(label, key, value).id();
}
@@ -158,23 +144,19 @@ public class BaseClientTest {
return edges.get(0);
}
- protected static void assertContains(List<PropertyKey> propertyKeys,
- PropertyKey propertyKey) {
+ protected static void assertContains(List<PropertyKey> propertyKeys,
PropertyKey propertyKey) {
Assert.assertTrue(Utils.contains(propertyKeys, propertyKey));
}
- protected static void assertContains(List<VertexLabel> vertexLabels,
- VertexLabel vertexLabel) {
+ protected static void assertContains(List<VertexLabel> vertexLabels,
VertexLabel vertexLabel) {
Assert.assertTrue(Utils.contains(vertexLabels, vertexLabel));
}
- protected static void assertContains(List<EdgeLabel> edgeLabels,
- EdgeLabel edgeLabel) {
+ protected static void assertContains(List<EdgeLabel> edgeLabels, EdgeLabel
edgeLabel) {
Assert.assertTrue(Utils.contains(edgeLabels, edgeLabel));
}
- protected static void assertContains(List<IndexLabel> indexLabels,
- IndexLabel indexLabel) {
+ protected static void assertContains(List<IndexLabel> indexLabels,
IndexLabel indexLabel) {
Assert.assertTrue(Utils.contains(indexLabels, indexLabel));
}
@@ -185,6 +167,7 @@ public class BaseClientTest {
schema.propertyKey("city").asText().ifNotExist().create();
schema.propertyKey("lang").asText().ifNotExist().create();
schema.propertyKey("date").asDate().ifNotExist().create();
+ schema.propertyKey("date @&$=*?").asDate().ifNotExist().create();
schema.propertyKey("price").asInt().ifNotExist().create();
schema.propertyKey("weight").asDouble().ifNotExist().create();
}
@@ -230,8 +213,8 @@ public class BaseClientTest {
schema.edgeLabel("created")
.sourceLabel("person")
.targetLabel("software")
- .properties("date", "city")
- .nullableKeys("city")
+ .properties("date", "date @&$=*?", "city")
+ .nullableKeys("city", "date @&$=*?")
.ifNotExist()
.create();
}
@@ -303,6 +286,16 @@ public class BaseClientTest {
"date", "2017-01-10", "city", "Hongkong");
}
+ @Before
+ public void setup() {
+ // this.clearData();
+ }
+
+ @After
+ public void teardown() throws Exception {
+ // pass
+ }
+
protected List<Vertex> create100PersonBatch() {
List<Vertex> vertices = new ArrayList<>(100);
for (int i = 0; i < 100; i++) {
diff --git
a/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java
b/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java
index a341e5ec..7e5cf611 100644
--- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java
+++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/SchemaApiTest.java
@@ -39,7 +39,7 @@ public class SchemaApiTest extends BaseApiTest {
Assert.assertTrue(schemas.containsKey("vertexlabels"));
Assert.assertTrue(schemas.containsKey("edgelabels"));
Assert.assertTrue(schemas.containsKey("indexlabels"));
- Assert.assertEquals(7, schemas.get("propertykeys").size());
+ Assert.assertEquals(8, schemas.get("propertykeys").size());
Assert.assertEquals(3, schemas.get("vertexlabels").size());
Assert.assertEquals(2, schemas.get("edgelabels").size());
Assert.assertTrue(schemas.get("indexlabels").isEmpty());
diff --git
a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java
b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java
index f2533ab8..826df089 100644
---
a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java
+++
b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/UserApiTest.java
@@ -49,6 +49,16 @@ public class UserApiTest extends AuthApiTest {
}
}
+ protected static User createUser(String name, String password) {
+ User user = new User();
+ user.name(name);
+ user.password(password);
+ user.email("[email protected]");
+ user.phone("16812345678");
+ user.avatar("image.jpg");
+ return api.create(user);
+ }
+
@Override
@After
public void teardown() {
@@ -136,15 +146,19 @@ public class UserApiTest extends AuthApiTest {
public void testGetUserRole() {
User user1 = createUser("test1", "psw1");
User user2 = createUser("test2", "psw2");
+ User user3 = createUser("test3 @&$=*?", "psw3");
Assert.assertEquals("test1", user1.name());
Assert.assertEquals("test2", user2.name());
+ Assert.assertContains("test3 @&$=*?", user3.name());// test special
character
UserRole role1 = api.getUserRole(user1.id());
UserRole role2 = api.getUserRole(user2.id());
+ UserRole role3 = api.getUserRole(user3.id());
Assert.assertEquals("{\"roles\":{}}", role1.toString());
Assert.assertEquals("{\"roles\":{}}", role2.toString());
+ Assert.assertEquals("{\"roles\":{}}", role3.toString());
}
@Test
@@ -256,14 +270,4 @@ public class UserApiTest extends AuthApiTest {
Assert.assertContains("Invalid user id: fake-id", e.getMessage());
});
}
-
- protected static User createUser(String name, String password) {
- User user = new User();
- user.name(name);
- user.password(password);
- user.email("[email protected]");
- user.phone("16812345678");
- user.avatar("image.jpg");
- return api.create(user);
- }
}
diff --git
a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java
b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java
index 4de5c3af..eafb2fe1 100644
---
a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java
+++
b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/EdgeTest.java
@@ -46,6 +46,20 @@ import com.google.common.collect.Iterators;
public class EdgeTest extends BaseFuncTest {
+ private static void assertContains(List<Edge> edges, Object source, String
label,
+ Object target, Object... keyValues) {
+ Map<String, Object> properties = Utils.asMap(keyValues);
+
+ Edge edge = new Edge(label);
+ edge.sourceId(source);
+ edge.targetId(target);
+ for (String key : properties.keySet()) {
+ edge.property(key, properties.get(key));
+ }
+
+ Assert.assertTrue(Utils.contains(edges, edge));
+ }
+
@Override
@Before
public void setup() {
@@ -66,8 +80,7 @@ public class EdgeTest extends BaseFuncTest {
Object peterId = getVertexId("person", "name", "peter");
Object lopId = getVertexId("software", "name", "lop");
- Edge created = graph().addEdge(peterId, "created", lopId,
- "date", "2017-03-24");
+ Edge created = graph().addEdge(peterId, "created", lopId, "date",
"2017-03-24");
Assert.assertTrue(created.linkedVertex(peterId));
Assert.assertTrue(created.linkedVertex(lopId));
}
@@ -77,15 +90,12 @@ public class EdgeTest extends BaseFuncTest {
Object peterId = getVertexId("person", "name", "peter");
Object lopId = getVertexId("software", "name", "lop");
- Edge created = graph().addEdge(peterId, "created", lopId,
- "date", "2017-03-24");
- Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"));
+ Edge created = graph().addEdge(peterId, "created", lopId, "date",
"2017-03-24");
+ Map<String, Object> props = ImmutableMap.of("date",
Utils.formatDate("2017-03-24"));
Assert.assertEquals(props, created.properties());
created.property("city", "HongKong");
- props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"),
- "city", "HongKong");
+ props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"),
"city", "HongKong");
Assert.assertEquals(props, created.properties());
}
@@ -94,10 +104,8 @@ public class EdgeTest extends BaseFuncTest {
Object peterId = getVertexId("person", "name", "peter");
Object lopId = getVertexId("software", "name", "lop");
- Edge created = graph().addEdge(peterId, "created", lopId,
- "date", "2017-03-24");
- Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"));
+ Edge created = graph().addEdge(peterId, "created", lopId, "date",
"2017-03-24");
+ Map<String, Object> props = ImmutableMap.of("date",
Utils.formatDate("2017-03-24"));
Assert.assertEquals(props, created.properties());
created.property("date", "2017-08-08");
@@ -125,16 +133,16 @@ public class EdgeTest extends BaseFuncTest {
"time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"),
- "time", ImmutableList.of(
- Utils.formatDate("2012-10-10")));
+ "date", Utils.formatDate("2017-03-24"),
+ "time", ImmutableList.of(
+ Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
created.property("time", "2014-02-14");
props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"),
"time", ImmutableList.of(
- Utils.formatDate("2012-10-10"),
- Utils.formatDate("2014-02-14")));
+ Utils.formatDate("2012-10-10"),
+ Utils.formatDate("2014-02-14")));
Assert.assertEquals(props, created.properties());
}
@@ -158,16 +166,16 @@ public class EdgeTest extends BaseFuncTest {
"time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"),
- "time", ImmutableList.of(
- Utils.formatDate("2012-10-10")));
+ "date", Utils.formatDate("2017-03-24"),
+ "time", ImmutableList.of(
+ Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
created.property("time", "2014-02-14");
props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"),
"time", ImmutableList.of(
- Utils.formatDate("2012-10-10"),
- Utils.formatDate("2014-02-14")));
+ Utils.formatDate("2012-10-10"),
+ Utils.formatDate("2014-02-14")));
Assert.assertEquals(props, created.properties());
}
@@ -191,16 +199,16 @@ public class EdgeTest extends BaseFuncTest {
"time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"),
- "time", ImmutableList.of(
- Utils.formatDate("2012-10-10")));
+ "date", Utils.formatDate("2017-03-24"),
+ "time", ImmutableList.of(
+ Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
created.property("time", "2012-10-10");
props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"),
"time", ImmutableList.of(
- Utils.formatDate("2012-10-10"),
- Utils.formatDate("2012-10-10")));
+ Utils.formatDate("2012-10-10"),
+ Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
}
@@ -224,15 +232,15 @@ public class EdgeTest extends BaseFuncTest {
"time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"),
- "time", ImmutableList.of(
- Utils.formatDate("2012-10-10")));
+ "date", Utils.formatDate("2017-03-24"),
+ "time", ImmutableList.of(
+ Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
created.property("time", "2012-10-10");
props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"),
"time", ImmutableList.of(
- Utils.formatDate("2012-10-10")));
+ Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
}
@@ -245,8 +253,8 @@ public class EdgeTest extends BaseFuncTest {
"city", "HongKong");
Edge created = graph().addEdge(peter, "created", lop, properties);
Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"),
- "city", "HongKong");
+ "date", Utils.formatDate("2017-03-24"),
+ "city", "HongKong");
Assert.assertEquals(props, created.properties());
}
@@ -270,9 +278,9 @@ public class EdgeTest extends BaseFuncTest {
"time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"),
- "time", ImmutableList.of(
- Utils.formatDate("2012-10-10")));
+ "date", Utils.formatDate("2017-03-24"),
+ "time", ImmutableList.of(
+ Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
created.removeProperty("time");
@@ -288,7 +296,7 @@ public class EdgeTest extends BaseFuncTest {
Edge created = graph().addEdge(peterId, "created", lopId,
"date", "2017-03-24");
Map<String, Object> props = ImmutableMap.of(
- "date", Utils.formatDate("2017-03-24"));
+ "date", Utils.formatDate("2017-03-24"));
Assert.assertEquals(props, created.properties());
Assert.assertThrows(InvalidOperationException.class, () -> {
@@ -464,8 +472,7 @@ public class EdgeTest extends BaseFuncTest {
Object lopId = getVertexId("software", "name", "lop");
Object rippleId = getVertexId("software", "name", "ripple");
- List<Edge> edges = graph().getEdges(joshId, Direction.OUT,
- "created");
+ List<Edge> edges = graph().getEdges(joshId, Direction.OUT, "created");
Assert.assertEquals(2, edges.size());
assertContains(edges, joshId, "created", rippleId,
"date", Utils.formatDate("2015-01-10"),
@@ -486,8 +493,7 @@ public class EdgeTest extends BaseFuncTest {
Object joshId = getVertexId("person", "name", "josh");
- List<Edge> edges = graph().getEdges(joshId, Direction.OUT,
- "created", 1);
+ List<Edge> edges = graph().getEdges(joshId, Direction.OUT, "created",
1);
Assert.assertEquals(1, edges.size());
for (Edge edge : edges) {
Assert.assertEquals(joshId, edge.sourceId());
@@ -510,11 +516,8 @@ public class EdgeTest extends BaseFuncTest {
Object joshId = getVertexId("person", "name", "josh");
Object rippleId = getVertexId("software", "name", "ripple");
- Map<String, Object> properties = ImmutableMap.of(
- "date",
- Utils.formatDate("2015-01-10"));
- List<Edge> edges = graph().getEdges(joshId, Direction.OUT,
- "created", properties);
+ Map<String, Object> properties = ImmutableMap.of("date",
Utils.formatDate("2015-01-10"));
+ List<Edge> edges = graph().getEdges(joshId, Direction.OUT, "created",
properties);
Assert.assertEquals(1, edges.size());
assertContains(edges, joshId, "created", rippleId,
"date", Utils.formatDate("2015-01-10"),
@@ -533,11 +536,8 @@ public class EdgeTest extends BaseFuncTest {
Object joshId = getVertexId("person", "name", "josh");
- Map<String, Object> properties = ImmutableMap.of(
- "date",
- Utils.formatDate("2015-01-10"));
- List<Edge> edges = graph().getEdges(joshId, Direction.OUT,
- "created", properties);
+ Map<String, Object> properties = ImmutableMap.of("date",
Utils.formatDate("2015-01-10"));
+ List<Edge> edges = graph().getEdges(joshId, Direction.OUT, "created",
properties);
Assert.assertEquals(1, edges.size());
for (Edge edge : edges) {
Assert.assertEquals(joshId, edge.sourceId());
@@ -555,7 +555,7 @@ public class EdgeTest extends BaseFuncTest {
@Test
public void testGetEdgesByLabelAndPropertiesWithRangeCondition()
- throws ParseException {
+ throws ParseException {
schema().indexLabel("knowsByDate").range()
.onE("knows").by("date").create();
schema().indexLabel("createdByDate").range()
@@ -566,8 +566,7 @@ public class EdgeTest extends BaseFuncTest {
Date expected = DateUtil.parse("2014-01-10");
Date expected2 = DateUtil.parse("2016-01-10");
- Map<String, Object> properties = ImmutableMap.of(
- "date", "P.eq(\"2014-1-10\")");
+ Map<String, Object> properties = ImmutableMap.of("date",
"P.eq(\"2014-1-10\")");
List<Edge> edges = graph().listEdges("created", properties);
Date time;
@@ -613,8 +612,7 @@ public class EdgeTest extends BaseFuncTest {
Assert.assertLte(expected.getTime(), time.getTime());
}
- properties = ImmutableMap.of("date",
- "P.between(\"2014-1-10\",\"2016-1-10\")");
+ properties = ImmutableMap.of("date",
"P.between(\"2014-1-10\",\"2016-1-10\")");
edges = graph().listEdges(null, properties);
Assert.assertEquals(2, edges.size());
for (Edge e : edges) {
@@ -624,8 +622,7 @@ public class EdgeTest extends BaseFuncTest {
Assert.assertLt(expected2.getTime(), time.getTime());
}
- properties = ImmutableMap.of("date",
- "P.inside(\"2014-1-10\",\"2016-1-10\")");
+ properties = ImmutableMap.of("date",
"P.inside(\"2014-1-10\",\"2016-1-10\")");
edges = graph().listEdges(null, properties);
Assert.assertEquals(1, edges.size());
for (Edge e : edges) {
@@ -635,8 +632,7 @@ public class EdgeTest extends BaseFuncTest {
Assert.assertLt(expected2.getTime(), time.getTime());
}
- properties = ImmutableMap.of("date",
- "P.within(\"2014-1-10\",\"2016-1-10\")");
+ properties = ImmutableMap.of("date",
"P.within(\"2014-1-10\",\"2016-1-10\")");
edges = graph().listEdges(null, properties);
Assert.assertEquals(2, edges.size());
for (Edge e : edges) {
@@ -647,9 +643,37 @@ public class EdgeTest extends BaseFuncTest {
}
}
+ @Test
+ public void testGetEdgesWithSpecialChars() {
+ schema().indexLabel("createdByCity").secondary()
+ .onE("created").by("city").create();
+ schema().indexLabel("createdByDate").secondary()
+ .onE("created").by("date @&$=*?").create();
+
+ Object markoId = getVertexId("person", "name", "marko");
+ Object lopId = getVertexId("software", "name", "lop");
+ Object rippleId = getVertexId("software", "name", "ripple");
+ graph().addEdge(markoId, "created", lopId,
+ "date", "2014-01-10", "city", "Shanghai", "date
@&$=*?", "2014-01-10");
+ graph().addEdge(markoId, "created", rippleId,
+ "date", "2015-01-10", "city", "Shanghai @&$=*?");
+
+ Map<String, Object> properties = ImmutableMap.of("date @&$=*?",
"P.eq(\"2014-1-10\")");
+ List<Edge> edges = graph().listEdges("created", properties, false);
+ Assert.assertEquals(1, edges.size());
+
+ Map<String, Object> properties2 = ImmutableMap.of("city", "Shanghai");
+ edges = graph().listEdges("created", properties2, true);
+ Assert.assertEquals(1, edges.size());
+
+ Map<String, Object> properties3 = ImmutableMap.of("city", "Shanghai
@&$=*?");
+ edges = graph().listEdges("created", properties3, true);
+ Assert.assertEquals(1, edges.size());
+ }
+
@Test
public void testGetEdgesByLabelAndPropertiesWithKeepP()
- throws ParseException {
+ throws ParseException {
schema().indexLabel("createdByCity").secondary()
.onE("created").by("city").create();
schema().indexLabel("createdByDate").secondary()
@@ -657,11 +681,11 @@ public class EdgeTest extends BaseFuncTest {
BaseClientTest.initEdge();
- Map<String, Object> properties = ImmutableMap.of(
- "date", "P.eq(\"2014-1-10\")");
+ Map<String, Object> properties = ImmutableMap.of("date",
"P.eq(\"2014-1-10\")");
List<Edge> edges = graph().listEdges("created", properties, false);
Assert.assertEquals(1, edges.size());
+
Assert.assertThrows(ServerException.class, () -> {
graph().listEdges("created", properties, true);
}, e -> {
@@ -705,10 +729,8 @@ public class EdgeTest extends BaseFuncTest {
edges = graph().iterateEdges(markoId, Direction.OUT, "created", 1);
Assert.assertEquals(1, Iterators.size(edges));
- Map<String, Object> properties = ImmutableMap.of("date",
- "P.gt(\"2012-1-1\")");
- Iterator<Edge> iter = graph().iterateEdges(markoId, Direction.OUT,
- "knows", properties, 1);
+ Map<String, Object> properties = ImmutableMap.of("date",
"P.gt(\"2012-1-1\")");
+ Iterator<Edge> iter = graph().iterateEdges(markoId, Direction.OUT,
"knows", properties, 1);
Assert.assertEquals(2, Iterators.size(iter));
}
@@ -775,23 +797,7 @@ public class EdgeTest extends BaseFuncTest {
.binding("vid", v1.id())
.execute();
}, e -> {
- Assert.assertContains("Can't query by paging and filtering",
- e.getMessage());
+ Assert.assertContains("Can't query by paging and filtering",
e.getMessage());
});
}
-
- private static void assertContains(List<Edge> edges, Object source,
- String label, Object target,
- Object... keyValues) {
- Map<String, Object> properties = Utils.asMap(keyValues);
-
- Edge edge = new Edge(label);
- edge.sourceId(source);
- edge.targetId(target);
- for (String key : properties.keySet()) {
- edge.property(key, properties.get(key));
- }
-
- Assert.assertTrue(Utils.contains(edges, edge));
- }
}
diff --git
a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java
b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java
index 5407da2a..7a93f1e8 100644
---
a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java
+++
b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/SchemaTest.java
@@ -40,7 +40,7 @@ public class SchemaTest extends BaseFuncTest {
Assert.assertTrue(schemas.containsKey("vertexlabels"));
Assert.assertTrue(schemas.containsKey("edgelabels"));
Assert.assertTrue(schemas.containsKey("indexlabels"));
- Assert.assertEquals(7, schemas.get("propertykeys").size());
+ Assert.assertEquals(8, schemas.get("propertykeys").size());
Assert.assertEquals(3, schemas.get("vertexlabels").size());
Assert.assertEquals(2, schemas.get("edgelabels").size());
Assert.assertTrue(schemas.get("indexlabels").isEmpty());
diff --git
a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java
b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java
index 360cdc5c..518552d3 100644
---
a/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java
+++
b/hugegraph-client/src/test/java/org/apache/hugegraph/unit/RestResultTest.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.hugegraph.driver.GraphManager;
+import org.apache.hugegraph.rest.RestHeaders;
import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.serializer.PathDeserializer;
import org.apache.hugegraph.structure.constant.Cardinality;
@@ -53,9 +54,11 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import lombok.SneakyThrows;
+
public class RestResultTest extends BaseUnitTest {
- private jakarta.ws.rs.core.Response mockResponse;
+ private okhttp3.Response mockResponse;
private static GraphManager graphManager;
@BeforeClass
@@ -74,7 +77,7 @@ public class RestResultTest extends BaseUnitTest {
@Before
public void setup() {
// Mock caches
- this.mockResponse = Mockito.mock(jakarta.ws.rs.core.Response.class);
+ this.mockResponse = Mockito.mock(okhttp3.Response.class,
Mockito.RETURNS_DEEP_STUBS);
}
@After
@@ -82,6 +85,7 @@ public class RestResultTest extends BaseUnitTest {
// pass
}
+ @SneakyThrows
@Test
public void testReadPropertyKey() {
String json = "{"
@@ -92,13 +96,12 @@ public class RestResultTest extends BaseUnitTest {
+ "\"properties\": []"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
- .thenReturn(json);
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string()).thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
PropertyKey propertyKey = result.readObject(PropertyKey.class);
@@ -108,6 +111,7 @@ public class RestResultTest extends BaseUnitTest {
Assert.assertEquals(Collections.emptySet(), propertyKey.properties());
}
+ @SneakyThrows
@Test
public void testReadPropertyKeys() {
String json = "{\"propertykeys\": ["
@@ -126,16 +130,14 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "]}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
- .thenReturn(json);
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string()).thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
- List<PropertyKey> propertyKeys = result.readList("propertykeys",
- PropertyKey.class);
+ List<PropertyKey> propertyKeys = result.readList("propertykeys",
PropertyKey.class);
Assert.assertEquals(2, propertyKeys.size());
PropertyKey propertyKey1 = propertyKeys.get(0);
PropertyKey propertyKey2 = propertyKeys.get(1);
@@ -151,6 +153,7 @@ public class RestResultTest extends BaseUnitTest {
Assert.assertEquals(Collections.emptySet(), propertyKey2.properties());
}
+ @SneakyThrows
@Test
public void testReadVertexLabel() {
String json = "{"
@@ -162,24 +165,22 @@ public class RestResultTest extends BaseUnitTest {
+ "\"properties\": [\"price\", \"name\", \"lang\"]"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
- .thenReturn(json);
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string()).thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
VertexLabel vertexLabel = result.readObject(VertexLabel.class);
Assert.assertEquals("software", vertexLabel.name());
Assert.assertEquals(IdStrategy.PRIMARY_KEY, vertexLabel.idStrategy());
- Assert.assertEquals(ImmutableList.of("name"),
- vertexLabel.primaryKeys());
- Assert.assertEquals(ImmutableSet.of("price", "name", "lang"),
- vertexLabel.properties());
+ Assert.assertEquals(ImmutableList.of("name"),
vertexLabel.primaryKeys());
+ Assert.assertEquals(ImmutableSet.of("price", "name", "lang"),
vertexLabel.properties());
}
+ @SneakyThrows
@Test
public void testReadVertexLabels() {
String json = "{\"vertexlabels\": ["
@@ -201,35 +202,30 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "]}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
- .thenReturn(json);
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string()).thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
- List<VertexLabel> vertexLabels = result.readList("vertexlabels",
- VertexLabel.class);
+ List<VertexLabel> vertexLabels = result.readList("vertexlabels",
VertexLabel.class);
Assert.assertEquals(2, vertexLabels.size());
VertexLabel vertexLabel1 = vertexLabels.get(0);
VertexLabel vertexLabel2 = vertexLabels.get(1);
Assert.assertEquals("software", vertexLabel1.name());
Assert.assertEquals(IdStrategy.PRIMARY_KEY, vertexLabel1.idStrategy());
- Assert.assertEquals(ImmutableList.of("name"),
- vertexLabel1.primaryKeys());
- Assert.assertEquals(ImmutableSet.of("price", "name", "lang"),
- vertexLabel1.properties());
+ Assert.assertEquals(ImmutableList.of("name"),
vertexLabel1.primaryKeys());
+ Assert.assertEquals(ImmutableSet.of("price", "name", "lang"),
vertexLabel1.properties());
Assert.assertEquals("person", vertexLabel2.name());
Assert.assertEquals(IdStrategy.CUSTOMIZE_STRING,
vertexLabel2.idStrategy());
- Assert.assertEquals(Collections.emptyList(),
- vertexLabel2.primaryKeys());
- Assert.assertEquals(ImmutableSet.of("city", "name", "age"),
- vertexLabel2.properties());
+ Assert.assertEquals(Collections.emptyList(),
vertexLabel2.primaryKeys());
+ Assert.assertEquals(ImmutableSet.of("city", "name", "age"),
vertexLabel2.properties());
}
+ @SneakyThrows
@Test
public void testReadEdgeLabel() {
String json = "{"
@@ -243,13 +239,12 @@ public class RestResultTest extends BaseUnitTest {
+ "\"frequency\": \"SINGLE\""
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
- .thenReturn(json);
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string()).thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
EdgeLabel edgeLabel = result.readObject(EdgeLabel.class);
@@ -261,6 +256,7 @@ public class RestResultTest extends BaseUnitTest {
Assert.assertEquals(ImmutableSet.of("date"), edgeLabel.properties());
}
+ @SneakyThrows
@Test
public void testReadEdgeLabels() {
String json = "{\"edgelabels\": ["
@@ -285,13 +281,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "]}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
List<EdgeLabel> edgeLabels = result.readList("edgelabels",
EdgeLabel.class);
@@ -315,6 +311,7 @@ public class RestResultTest extends BaseUnitTest {
edgeLabel2.properties());
}
+ @SneakyThrows
@Test
public void testReadIndexLabel() {
String json = "{"
@@ -326,13 +323,13 @@ public class RestResultTest extends BaseUnitTest {
+ "\"base_type\": \"VERTEX_LABEL\""
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
IndexLabel indexLabel = result.readObject(IndexLabel.class);
@@ -344,6 +341,7 @@ public class RestResultTest extends BaseUnitTest {
indexLabel.indexFields());
}
+ @SneakyThrows
@Test
public void testReadIndexLabels() {
String json = "{\"indexlabels\": ["
@@ -365,13 +363,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "]}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
List<IndexLabel> indexLabels = result.readList("indexlabels",
IndexLabel.class);
@@ -394,6 +392,7 @@ public class RestResultTest extends BaseUnitTest {
indexLabel2.indexFields());
}
+ @SneakyThrows
@Test
public void testReadVertex() {
String json = "{"
@@ -405,13 +404,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
Vertex vertex = result.readObject(Vertex.class);
@@ -421,6 +420,7 @@ public class RestResultTest extends BaseUnitTest {
vertex.properties());
}
+ @SneakyThrows
@Test
public void testReadVertices() {
String json = "{\"vertices\": ["
@@ -456,13 +456,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "]}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
List<Vertex> vertices = result.readList("vertices", Vertex.class);
Assert.assertEquals(3, vertices.size());
@@ -497,6 +497,7 @@ public class RestResultTest extends BaseUnitTest {
vertex3.properties());
}
+ @SneakyThrows
@Test
public void testReadEdge() {
String json = "{"
@@ -513,13 +514,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
Edge edge = result.readObject(Edge.class);
@@ -529,11 +530,11 @@ public class RestResultTest extends BaseUnitTest {
Assert.assertEquals("software:lop", edge.targetId());
Assert.assertEquals("person", edge.sourceLabel());
Assert.assertEquals("software", edge.targetLabel());
- Assert.assertEquals(ImmutableMap.of("city", "Hongkong",
- "date", 1495036800000L),
+ Assert.assertEquals(ImmutableMap.of("city", "Hongkong", "date",
1495036800000L),
edge.properties());
}
+ @SneakyThrows
@Test
public void testReadEdges() {
String json = "{\"edges\": ["
@@ -564,13 +565,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "]}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult result = new RestResult(this.mockResponse);
Assert.assertEquals(200, result.status());
- Assert.assertNull(result.headers());
+ Assert.assertEquals(result.headers(), new RestHeaders());
List<Edge> edges = result.readList("edges", Edge.class);
Assert.assertEquals(2, edges.size());
@@ -597,6 +598,7 @@ public class RestResultTest extends BaseUnitTest {
edge2.properties());
}
+ @SneakyThrows
@Test
public void testReadGremlinVertices() {
String json = "{"
@@ -643,13 +645,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult restResult = new RestResult(this.mockResponse);
Assert.assertEquals(200, restResult.status());
- Assert.assertNull(restResult.headers());
+ Assert.assertEquals(restResult.headers(), new RestHeaders());
Response response = restResult.readObject(Response.class);
response.graphManager(graph());
@@ -689,6 +691,7 @@ public class RestResultTest extends BaseUnitTest {
}
}
+ @SneakyThrows
@Test
public void testReadGremlinEdges() {
String json = "{"
@@ -731,13 +734,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult restResult = new RestResult(this.mockResponse);
Assert.assertEquals(200, restResult.status());
- Assert.assertNull(restResult.headers());
+ Assert.assertEquals(restResult.headers(), new RestHeaders());
Response response = restResult.readObject(Response.class);
response.graphManager(graph());
@@ -774,6 +777,7 @@ public class RestResultTest extends BaseUnitTest {
}
}
+ @SneakyThrows
@Test
public void testReadGremlinPathWithVertexAndEdge() {
String json = "{"
@@ -819,13 +823,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult restResult = new RestResult(this.mockResponse);
Assert.assertEquals(200, restResult.status());
- Assert.assertNull(restResult.headers());
+ Assert.assertEquals(restResult.headers(), new RestHeaders());
Response response = restResult.readObject(Response.class);
response.graphManager(graph());
@@ -862,6 +866,7 @@ public class RestResultTest extends BaseUnitTest {
path.objects());
}
+ @SneakyThrows
@Test
public void testReadGremlinNullData() {
String json = "{"
@@ -877,13 +882,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult restResult = new RestResult(this.mockResponse);
Assert.assertEquals(200, restResult.status());
- Assert.assertNull(restResult.headers());
+ Assert.assertEquals(restResult.headers(), new RestHeaders());
Response response = restResult.readObject(Response.class);
response.graphManager(graph());
@@ -895,6 +900,7 @@ public class RestResultTest extends BaseUnitTest {
Assert.assertNull(object);
}
+ @SneakyThrows
@Test
public void testReadGremlinNullAndVertex() {
String json = "{"
@@ -922,13 +928,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult restResult = new RestResult(this.mockResponse);
Assert.assertEquals(200, restResult.status());
- Assert.assertNull(restResult.headers());
+ Assert.assertEquals(restResult.headers(), new RestHeaders());
Response response = restResult.readObject(Response.class);
response.graphManager(graph());
@@ -952,6 +958,7 @@ public class RestResultTest extends BaseUnitTest {
Assert.assertTrue(Utils.contains(ImmutableList.of(marko), vertex));
}
+ @SneakyThrows
@Test
public void testReadGremlinEdgeAndNull() {
String json = "{"
@@ -982,13 +989,13 @@ public class RestResultTest extends BaseUnitTest {
+ "}"
+ "}";
- Mockito.when(this.mockResponse.getStatus()).thenReturn(200);
- Mockito.when(this.mockResponse.getHeaders()).thenReturn(null);
- Mockito.when(this.mockResponse.readEntity(String.class))
+ Mockito.when(this.mockResponse.code()).thenReturn(200);
+ Mockito.when(this.mockResponse.headers()).thenReturn(null);
+ Mockito.when(this.mockResponse.body().string())
.thenReturn(json);
RestResult restResult = new RestResult(this.mockResponse);
Assert.assertEquals(200, restResult.status());
- Assert.assertNull(restResult.headers());
+ Assert.assertEquals(restResult.headers(), new RestHeaders());
Response response = restResult.readObject(Response.class);
response.graphManager(graph());
@@ -1008,8 +1015,7 @@ public class RestResultTest extends BaseUnitTest {
created.targetLabel("software");
created.property("date", 1490284800000L);
created.property("weight", 0.2);
- Assert.assertTrue(Utils.contains(ImmutableList.of(created),
- result.getEdge()));
+ Assert.assertTrue(Utils.contains(ImmutableList.of(created),
result.getEdge()));
Assert.assertTrue(results.hasNext());
result = results.next();
diff --git
a/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
new file mode 100644
index 00000000..a76010b2
--- /dev/null
+++
b/hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+mock-maker-inline
diff --git a/hugegraph-dist/scripts/dependency/known-dependencies.txt
b/hugegraph-dist/scripts/dependency/known-dependencies.txt
index bacffaed..83add0d2 100644
--- a/hugegraph-dist/scripts/dependency/known-dependencies.txt
+++ b/hugegraph-dist/scripts/dependency/known-dependencies.txt
@@ -3,10 +3,10 @@ accessors-smart-2.4.2.jar
aircompressor-0.10.jar
aircompressor-0.21.jar
annotations-17.0.0.jar
+annotations-13.0.jar
ant-1.9.1.jar
ant-launcher-1.9.1.jar
antlr-runtime-3.5.2.jar
-aopalliance-repackaged-3.0.1.jar
apache-curator-2.12.0.pom
arrow-format-0.8.0.jar
arrow-format-2.0.0.jar
@@ -110,9 +110,6 @@ hive-storage-api-2.7.0.jar
hive-storage-api-2.7.2.jar
hive-upgrade-acid-3.1.3.jar
hive-vector-code-gen-3.1.3.jar
-hk2-api-3.0.1.jar
-hk2-locator-3.0.1.jar
-hk2-utils-3.0.1.jar
hppc-0.7.2.jar
htrace-core4-4.1.0-incubating.jar
htrace-core4-4.2.0-incubating.jar
@@ -136,12 +133,11 @@ jackson-module-jaxb-annotations-2.12.3.jar
jackson-module-parameter-names-2.12.3.jar
jakarta.activation-2.0.1.jar
jakarta.activation-api-1.2.1.jar
-jakarta.annotation-api-2.0.0.jar
-jakarta.inject-api-2.0.0.jar
-jakarta.validation-api-3.0.0.jar
-jakarta.ws.rs-api-3.0.0.jar
+jersey-container-servlet-core-2.25.1.jar
+jersey-container-servlet-core-2.27.jar
+javax.inject-2.5.0-b32.jar
+javax.inject-2.5.0-b42.jar
jakarta.xml.bind-api-2.3.2.jar
-jakarta.xml.bind-api-4.0.0-RC2.jar
jamon-runtime-2.4.1.jar
javassist-3.24.0-GA.jar
javassist-3.25.0-GA.jar
@@ -165,15 +161,6 @@ jcip-annotations-1.0-1.jar
jcodings-1.0.18.jar
jcommander-1.72.jar
jcommander-1.78.jar
-jersey-apache-connector-3.0.3.jar
-jersey-client-3.0.3.jar
-jersey-common-3.0.3.jar
-jersey-container-servlet-3.0.3.jar
-jersey-container-servlet-core-3.0.3.jar
-jersey-entity-filtering-3.0.3.jar
-jersey-hk2-3.0.3.jar
-jersey-media-json-jackson-3.0.3.jar
-jersey-server-3.0.3.jar
jetty-client-9.4.33.v20201020.jar
jetty-client-9.4.40.v20210413.jar
jetty-http-9.4.19.v20190610.jar
@@ -267,13 +254,22 @@ netty-transport-native-epoll-4.1.65.Final.jar
netty-transport-native-unix-common-4.1.65.Final.jar
nimbus-jose-jwt-9.8.1.jar
okhttp-2.7.5.jar
+okhttp-4.10.0.jar
+logging-interceptor-4.10.0.jar
+kotlin-stdlib-1.2.71.jar
+kotlin-stdlib-1.6.20.jar
+kotlin-stdlib-common-1.5.31.jar
+kotlin-stdlib-jdk7-1.2.71.jar
+kotlin-stdlib-jdk7-1.6.10.jar
+kotlin-stdlib-jdk8-1.2.71.jar
+kotlin-stdlib-jdk8-1.6.10.jar
okio-1.6.0.jar
+okio-jvm-3.0.0.jar
opencsv-2.3.jar
orc-core-1.5.8.jar
orc-core-1.6.14.jar
orc-shims-1.5.8.jar
orc-shims-1.6.14.jar
-osgi-resource-locator-1.0.3.jar
ow2-asm-6.2.jar
paranamer-2.3.jar
postgresql-42.2.6.jar
diff --git a/hugegraph-hubble/hubble-be/pom.xml
b/hugegraph-hubble/hubble-be/pom.xml
index fe7b686d..301c6c34 100644
--- a/hugegraph-hubble/hubble-be/pom.xml
+++ b/hugegraph-hubble/hubble-be/pom.xml
@@ -1,20 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
+ 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.
+ 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.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -31,6 +33,7 @@
<app.port>36320</app.port>
<mybatis.starter.version>2.1.0</mybatis.starter.version>
<mybatis.plus.starter.version>3.3.0</mybatis.plus.starter.version>
+ <okhttp.version>4.10.0</okhttp.version>
</properties>
<dependencies>
@@ -89,10 +92,6 @@
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.hugegraph</groupId>
- <artifactId>hugegraph-common</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.hugegraph</groupId>
@@ -127,10 +126,6 @@
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
</exclusion>
- <exclusion>
- <groupId>org.apache.hugegraph</groupId>
- <artifactId>hugegraph-common</artifactId>
- </exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
@@ -139,15 +134,51 @@
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
+ <exclusion>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.squareup.okhttp</groupId>
+ <artifactId>okhttp</artifactId>
+ </exclusion>
</exclusions>
</dependency>
+ <!--overwrite okhttp and kotlin for version conflict-->
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib</artifactId>
+ <version>1.6.20</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib-common</artifactId>
+ <version>1.5.31</version>
+ </dependency>
+
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
</dependencies>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp-bom</artifactId>
+ <version>${okhttp.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<profiles>
<profile>
<id>unit-test</id>
diff --git a/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh
b/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh
index 38a7032c..1a08376d 100755
--- a/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh
+++ b/hugegraph-hubble/hubble-dist/assembly/travis/download-hugegraph.sh
@@ -1,19 +1,19 @@
#!/bin/bash
#
# 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
+# 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
+# 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.
+# 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.
#
set -ev
diff --git a/hugegraph-hubble/pom.xml b/hugegraph-hubble/pom.xml
index e9f239b4..5af407ab 100644
--- a/hugegraph-hubble/pom.xml
+++ b/hugegraph-hubble/pom.xml
@@ -30,7 +30,7 @@
<packaging>pom</packaging>
<name>${project.artifactId}</name>
-
<url>https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-hubble</url>
+
<url>https://github.com/apache/hugegraph-toolchain/tree/master/hugegraph-hubble</url>
<description>
hugegraph-hubble is a graph management and analysis platform that
provides features:
graph data load, schema management, graph relationship analysis and
graphical display.
@@ -47,13 +47,6 @@
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.glassfish.jersey</groupId>
- <artifactId>jersey-bom</artifactId>
- <version>${jersey.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
diff --git a/hugegraph-loader/pom.xml b/hugegraph-loader/pom.xml
index e6d121be..e4565f0f 100644
--- a/hugegraph-loader/pom.xml
+++ b/hugegraph-loader/pom.xml
@@ -30,11 +30,11 @@
<packaging>jar</packaging>
<name>${project.artifactId}</name>
-
<url>https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-loader</url>
+
<url>https://github.com/apache/hugegraph-toolchain/tree/master/hugegraph-loader</url>
<description>
hugegraph-loader is a customizable command line utility for loading
small to medium size
- graph datasets
- into the HugeGraph database from multiple data sources with various
input formats.
+ graph datasets into the HugeGraph database from multiple data sources
with various
+ input formats.
</description>
<properties>
@@ -366,6 +366,7 @@
<artifactId>hadoop-hdfs-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
+ <!-- TODO: slim hadoop depedenencies -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapred</artifactId>
diff --git a/hugegraph-spark-connector/pom.xml
b/hugegraph-spark-connector/pom.xml
index 5f595f07..b5e249b0 100644
--- a/hugegraph-spark-connector/pom.xml
+++ b/hugegraph-spark-connector/pom.xml
@@ -36,10 +36,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spark.verion>3.2.2</spark.verion>
<spark.scope>provided</spark.scope>
- <hugegraph.client.version>1.0.0</hugegraph.client.version>
<jackson.version>2.12.3</jackson.version>
- <jersey.version>3.0.3</jersey.version>
-
<jersey.container.servlet.core.version>2.34</jersey.container.servlet.core.version>
<log4j.version>2.18.0</log4j.version>
<slf4j.api.version>1.7.25</slf4j.api.version>
<scala.minor.version>2.12.11</scala.minor.version>
@@ -91,36 +88,7 @@
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
- <version>${hugegraph.client.version}</version>
- </dependency>
-
- <!-- jersey version override -->
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-client</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-common</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.inject</groupId>
- <artifactId>jersey-hk2</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-server</artifactId>
- <version>${jersey.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet-core</artifactId>
- <version>${jersey.container.servlet.core.version}</version>
- <scope>provided</scope>
+ <version>${revision}</version>
</dependency>
<!-- jackson version override -->
diff --git a/pom.xml b/pom.xml
index 00d1ecd4..ed3aa7c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,8 @@
<name>${project.artifactId}</name>
<url>https://github.com/apache/incubator-hugegraph-toolchain</url>
<description>
- hugegraph-toolchain is the integration project of a series of
utilities for HugeGraph, it includes 4 main modules (loader/hubble/tools/client)
+ hugegraph-toolchain is the integration project of a series of
utilities for HugeGraph,
+ it includes 4 main modules (loader/hubble/tools/client)
</description>
<parent>
@@ -97,7 +98,8 @@
</modules>
<properties>
- <revision>1.0.0</revision>
+ <revision>1.2.0</revision>
+ <hugegraph.common.version>1.2.0</hugegraph.common.version>
<release.name>${project.artifactId}</release.name>
<final.name>apache-${release.name}-incubating-${project.version}</final.name>
<assembly.dir>${project.basedir}/assembly</assembly.dir>
@@ -120,12 +122,10 @@
<docker.hub>hugegraph</docker.hub>
<docker.repo>${project.name}</docker.repo>
<docker.tag>${project.version}</docker.tag>
- <hugegraph.common.version>1.0.0</hugegraph.common.version>
<hive.version>3.1.3</hive.version>
<hbase.version>2.2.3</hbase.version>
<hadoop.version>3.3.1</hadoop.version>
<zookeeper.version>3.6.2</zookeeper.version>
- <jersey.version>3.0.3</jersey.version>
<junit.version>4.12</junit.version>
<mockito.version>2.8.47</mockito.version>
<lombok.version>1.18.8</lombok.version>
@@ -152,13 +152,6 @@
<!-- submodules will not inherit the dependencies unless they address it
-->
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.glassfish.jersey</groupId>
- <artifactId>jersey-bom</artifactId>
- <version>${jersey.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>