Skip to content

Commit

Permalink
fix deserialize error of edge label, switch mockito version
Browse files Browse the repository at this point in the history
  • Loading branch information
Thespica committed Oct 4, 2024
1 parent 0c25411 commit d9f03e2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 31 deletions.
2 changes: 2 additions & 0 deletions hugegraph-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<!-- <version>${mockito.version}</version>-->
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit d9f03e2

Please sign in to comment.