From d9f03e28e71347d3fb37d143b15e4240b95afe73 Mon Sep 17 00:00:00 2001 From: Thespica Date: Fri, 4 Oct 2024 15:24:49 +0800 Subject: [PATCH] fix deserialize error of edge label, switch mockito version --- hugegraph-client/pom.xml | 2 + .../hugegraph/structure/schema/EdgeLabel.java | 2 + .../apache/hugegraph/unit/RestResultTest.java | 85 ++++++++++++------- 3 files changed, 58 insertions(+), 31 deletions(-) diff --git a/hugegraph-client/pom.xml b/hugegraph-client/pom.xml index 08b8d3ebe..0156ecec8 100644 --- a/hugegraph-client/pom.xml +++ b/hugegraph-client/pom.xml @@ -48,6 +48,8 @@ org.mockito mockito-core + + 2.25.1 test diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java b/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java index 729c3c787..62633443e 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java @@ -286,6 +286,7 @@ public Builder asGeneral() { } + // TODO(@Thespcia): should be marked as @Deprecated? @Override public Builder sourceLabel(String label) { E.checkArgument(this.edgeLabel.links.isEmpty(), @@ -295,6 +296,7 @@ public Builder sourceLabel(String label) { return this; } + // TODO(@Thespcia): should be marked as @Deprecated? @Override public Builder targetLabel(String label) { E.checkArgument(this.edgeLabel.links.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 518552d3f..70ff43e0f 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 @@ -228,16 +228,21 @@ public void testReadVertexLabels() { @SneakyThrows @Test public void testReadEdgeLabel() { - String json = "{" - + "\"id\": 2," - + "\"source_label\": \"person\"," - + "\"index_labels\": [\"createdByDate\"]," - + "\"name\": \"created\"," - + "\"target_label\": \"software\"," - + "\"sort_keys\": []," - + "\"properties\": [\"date\"]," - + "\"frequency\": \"SINGLE\"" - + "}"; + String json = "{\n" + + " \"id\" : 14,\n" + + " \"name\" : \"created\",\n" + + " \"edgelabel_type\" : \"NORMAL\",\n" + + " \"links\" : [ {\n" + + " \"person\" : \"software\"\n" + + " } ],\n" + + " \"frequency\" : \"SINGLE\",\n" + + " \"sort_keys\" : [ ],\n" + + " \"nullable_keys\" : [ ],\n" + + " \"index_labels\" : [ ],\n" + + " \"properties\" : [ \"date\" ],\n" + + " \"status\" : \"CREATED\",\n" + + " \"enable_label_index\" : true,\n" + + "}"; Mockito.when(this.mockResponse.code()).thenReturn(200); Mockito.when(this.mockResponse.headers()).thenReturn(null); @@ -259,27 +264,45 @@ public void testReadEdgeLabel() { @SneakyThrows @Test public void testReadEdgeLabels() { - String json = "{\"edgelabels\": [" - + "{" - + "\"id\": 2," - + "\"source_label\": \"person\"," - + "\"index_labels\": [\"createdByDate\"]," - + "\"name\": \"created\"," - + "\"target_label\": \"software\"," - + "\"sort_keys\": []," - + "\"properties\": [\"date\"]," - + "\"frequency\": \"SINGLE\"" - + "}," - + "{\"id\": 3," - + "\"source_label\": \"person\"," - + "\"index_labels\": []," - + "\"name\": \"knows\"," - + "\"target_label\": \"person\"," - + "\"sort_keys\": []," - + "\"properties\": [\"date\", \"city\"]," - + "\"frequency\": \"SINGLE\"" - + "}" - + "]}"; + String json = "{\n" + + " \"edgelabels\" : [ {\n" + + " \"id\" : 32,\n" + + " \"name\" : \"created\",\n" + + " \"edgelabel_type\" : \"NORMAL\",\n" + + " \"links\" : [ {\n" + + " \"person\" : \"software\"\n" + + " } ],\n" + + " \"frequency\" : \"SINGLE\",\n" + + " \"sort_keys\" : [ ],\n" + + " \"nullable_keys\" : [ ],\n" + + " \"index_labels\" : [ ],\n" + + " \"properties\" : [ \"date\" ],\n" + + " \"status\" : \"CREATED\",\n" + + " \"ttl\" : 0,\n" + + " \"enable_label_index\" : true,\n" + + " \"user_data\" : {\n" + + " \"~create_time\" : \"2024-10-04 15:17:10.061\"\n" + + " }\n" + + " }, {\n" + + " \"id\" : 31,\n" + + " \"name\" : \"knows\",\n" + + " \"edgelabel_type\" : \"NORMAL\",\n" + + " \"links\" : [ {\n" + + " \"person\" : \"person\"\n" + + " } ],\n" + + " \"frequency\" : \"SINGLE\",\n" + + " \"sort_keys\" : [ ],\n" + + " \"nullable_keys\" : [ ],\n" + + " \"index_labels\" : [ ],\n" + + " \"properties\" : [ \"city\", \"date\" ],\n" + + " \"status\" : \"CREATED\",\n" + + " \"ttl\" : 0,\n" + + " \"enable_label_index\" : true,\n" + + " \"user_data\" : {\n" + + " \"~create_time\" : \"2024-10-04 15:17:10.053\"\n" + + " }\n" + + " } ]\n" + + "}"; Mockito.when(this.mockResponse.code()).thenReturn(200); Mockito.when(this.mockResponse.headers()).thenReturn(null);