From d226f97b40ea70d2d801c63c02a005ee02475d60 Mon Sep 17 00:00:00 2001 From: zhangyi51 Date: Tue, 24 Aug 2021 13:31:11 +0800 Subject: [PATCH 1/2] update property create and update http return code Change-Id: I0463c6326863a6c882408737b3dfe2e12adabeaa --- .../java/com/baidu/hugegraph/api/schema/PropertyKeyAPI.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/schema/PropertyKeyAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/schema/PropertyKeyAPI.java index 18736f86f0..4c3e99b311 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/schema/PropertyKeyAPI.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/schema/PropertyKeyAPI.java @@ -69,7 +69,7 @@ public class PropertyKeyAPI extends API { @POST @Timed - @Status(Status.CREATED) + @Status(Status.ACCEPTED) @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed({"admin", "$owner=$graph $action=property_key_write"}) @@ -88,6 +88,7 @@ public String create(@Context GraphManager manager, @PUT @Timed + @Status(Status.ACCEPTED) @Path("{name}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON_WITH_CHARSET) From cec43d64cdcc96618f05a0ad577e76538f57bed7 Mon Sep 17 00:00:00 2001 From: zhangyi51 Date: Tue, 24 Aug 2021 15:09:08 +0800 Subject: [PATCH 2/2] adapt for api test Change-Id: I252f5cab53c2f0de8506342cfb7c9ab0178fc1d6 --- .../com/baidu/hugegraph/api/BaseApiTest.java | 21 ++++++++++++------- .../baidu/hugegraph/api/GremlinApiTest.java | 4 ++-- .../hugegraph/api/PropertyKeyApiTest.java | 8 +++---- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java index 68e328237a..213f8a8b13 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java @@ -202,49 +202,49 @@ protected static void initPropertyKey() { + "\"cardinality\": \"SINGLE\",\n" + "\"check_exist\": false,\n" + "\"properties\":[]\n" - + "}"); + + "}", 202); createAndAssert(path, "{\n" + "\"name\": \"age\",\n" + "\"data_type\": \"INT\",\n" + "\"cardinality\": \"SINGLE\",\n" + "\"check_exist\": false,\n" + "\"properties\":[]\n" - + "}"); + + "}", 202); createAndAssert(path, "{\n" + "\"name\": \"city\",\n" + "\"data_type\": \"TEXT\",\n" + "\"cardinality\": \"SINGLE\",\n" + "\"check_exist\": false,\n" + "\"properties\":[]\n" - + "}"); + + "}", 202); createAndAssert(path, "{\n" + "\"name\": \"lang\",\n" + "\"data_type\": \"TEXT\",\n" + "\"cardinality\": \"SINGLE\",\n" + "\"check_exist\": false,\n" + "\"properties\":[]\n" - + "}"); + + "}", 202); createAndAssert(path, "{\n" + "\"name\": \"date\",\n" + "\"data_type\": \"TEXT\",\n" + "\"cardinality\": \"SINGLE\",\n" + "\"check_exist\": false,\n" + "\"properties\":[]\n" - + "}"); + + "}", 202); createAndAssert(path, "{\n" + "\"name\": \"price\",\n" + "\"data_type\": \"INT\",\n" + "\"cardinality\": \"SINGLE\",\n" + "\"check_exist\": false,\n" + "\"properties\":[]\n" - + "}"); + + "}", 202); createAndAssert(path, "{\n" + "\"name\": \"weight\",\n" + "\"data_type\": \"DOUBLE\",\n" + "\"cardinality\": \"SINGLE\",\n" + "\"check_exist\": false,\n" + "\"properties\":[]\n" - + "}"); + + "}", 202); } protected static void initVertexLabel() { @@ -427,8 +427,13 @@ protected static void initVertex() { } protected static Response createAndAssert(String path, String body) { + return createAndAssert(path, body, 201); + } + + protected static Response createAndAssert(String path, String body, + int status) { Response r = client.post(path, body); - assertResponseStatus(201, r); + assertResponseStatus(status, r); return r; } diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java index ee18ddb2b9..c983ca1134 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/GremlinApiTest.java @@ -127,7 +127,7 @@ public void testSetVertexProperty() { + "\"cardinality\": \"SINGLE\"," + "\"properties\":[]" + "}"; - assertResponseStatus(201, client().post(pkPath, foo)); + assertResponseStatus(202, client().post(pkPath, foo)); // Cardinality list String bar = "{" + "\"name\": \"bar\"," @@ -135,7 +135,7 @@ public void testSetVertexProperty() { + "\"cardinality\": \"LIST\"," + "\"properties\":[]" + "}"; - assertResponseStatus(201, client().post(pkPath, bar)); + assertResponseStatus(202, client().post(pkPath, bar)); String vlPath = "/graphs/hugegraph/schema/vertexlabels/"; String vertexLabel = "{" diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/PropertyKeyApiTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/PropertyKeyApiTest.java index 6137b6f034..4eff83ee43 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/api/PropertyKeyApiTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/api/PropertyKeyApiTest.java @@ -38,7 +38,7 @@ public void testCreate() { + "\"properties\":[]" + "}"; Response r = client().post(path, propertyKey); - assertResponseStatus(201, r); + assertResponseStatus(202, r); } @Test @@ -50,7 +50,7 @@ public void testGet() { + "\"properties\":[]" + "}"; Response r = client().post(path, propertyKey); - assertResponseStatus(201, r); + assertResponseStatus(202, r); String name = "id"; r = client().get(path, name); @@ -66,7 +66,7 @@ public void testList() { + "\"properties\":[]" + "}"; Response r = client().post(path, propertyKey); - assertResponseStatus(201, r); + assertResponseStatus(202, r); r = client().get(path); assertResponseStatus(200, r); @@ -81,7 +81,7 @@ public void testDelete() { + "\"properties\":[]" + "}"; Response r = client().post(path, propertyKey); - assertResponseStatus(201, r); + assertResponseStatus(202, r); String name = "id"; r = client().delete(path, name);