Skip to content

Commit

Permalink
refact: move java class to test/java & fix test code check-style (#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyYangPassion authored May 12, 2022
1 parent d4304b6 commit 2d25938
Show file tree
Hide file tree
Showing 60 changed files with 1,343 additions and 1,207 deletions.
406 changes: 203 additions & 203 deletions hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java

Large diffs are not rendered by default.

186 changes: 93 additions & 93 deletions hugegraph-test/src/main/java/com/baidu/hugegraph/api/EdgeApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ public void testCreate() throws IOException {
String outVId = getVertexId("person", "name", "peter");
String inVId = getVertexId("software", "name", "lop");

String edge = String.format("{"
+ "\"label\": \"created\","
+ "\"outVLabel\": \"person\","
+ "\"inVLabel\": \"software\","
+ "\"outV\": \"%s\","
+ "\"inV\": \"%s\","
+ "\"properties\":{"
+ "\"date\": \"20170324\","
+ "\"weight\": 0.5}"
+ "}", outVId, inVId);
String edge = String.format("{" +
"\"label\": \"created\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"properties\":{" +
"\"date\": \"20170324\"," +
"\"weight\": 0.5}" +
"}", outVId, inVId);
Response r = client().post(path, edge);
assertResponseStatus(201, r);
}
Expand All @@ -64,44 +64,44 @@ public void testBatchUpdate() throws IOException {
String outVId = getVertexId("person", "name", "marko");
String inVId = getVertexId("person", "name", "josh");
// Create
String edge = String.format("{"
+ "\"label\": \"knows\","
+ "\"outVLabel\": \"person\","
+ "\"inVLabel\": \"person\","
+ "\"outV\": \"%s\","
+ "\"inV\": \"%s\","
+ "\"properties\":{"
+ "\"date\": \"2013-02-20\","
+ "\"weight\": 1.0}"
+ "}", outVId, inVId);
String edge = String.format("{" +
"\"label\": \"knows\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"person\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"properties\":{" +
"\"date\": \"2013-02-20\"," +
"\"weight\": 1.0}" +
"}", outVId, inVId);
Response r = client().post(path, edge);
// The edge id is 'S1:marko>1>7JooBil0>S1:josh'
String content = assertResponseStatus(201, r);
String edgeId = parseId(content);

// Update edge with edgeId
edge = String.format("{"
+ "\"edges\":["
+ "{"
+ "\"id\":\"%s\","
+ "\"label\":\"knows\","
+ "\"outV\":\"%s\","
+ "\"outVLabel\":\"person\","
+ "\"inV\":\"%s\","
+ "\"inVLabel\":\"person\","
+ "\"properties\":{"
+ "\"weight\":0.2,"
+ "\"date\":\"2014-02-20\""
+ "}"
+ "}"
+ "],"
+ "\"update_strategies\":{"
+ "\"weight\":\"SUM\","
+ "\"date\":\"BIGGER\""
+ "},"
+ "\"check_vertex\":false,"
+ "\"create_if_not_exist\":true"
+ "}", edgeId, outVId, inVId);
edge = String.format("{" +
"\"edges\":[" +
"{" +
"\"id\":\"%s\"," +
"\"label\":\"knows\"," +
"\"outV\":\"%s\"," +
"\"outVLabel\":\"person\"," +
"\"inV\":\"%s\"," +
"\"inVLabel\":\"person\"," +
"\"properties\":{" +
"\"weight\":0.2," +
"\"date\":\"2014-02-20\"" +
"}" +
"}" +
"]," +
"\"update_strategies\":{" +
"\"weight\":\"SUM\"," +
"\"date\":\"BIGGER\"" +
"}," +
"\"check_vertex\":false," +
"\"create_if_not_exist\":true" +
"}", edgeId, outVId, inVId);
r = client().put(path, "batch", edge, ImmutableMap.of());
// Now allowed to modify sortkey values, the property 'date' has changed
content = assertResponseStatus(400, r);
Expand All @@ -110,27 +110,27 @@ public void testBatchUpdate() throws IOException {
"specified edge id"));

// Update edge without edgeId
edge = String.format("{"
+ "\"edges\":["
+ "{"
+ "\"label\":\"knows\","
+ "\"outV\":\"%s\","
+ "\"outVLabel\":\"person\","
+ "\"inV\":\"%s\","
+ "\"inVLabel\":\"person\","
+ "\"properties\":{"
+ "\"weight\":0.2,"
+ "\"date\":\"2014-02-20\""
+ "}"
+ "}"
+ "],"
+ "\"update_strategies\":{"
+ "\"weight\":\"SUM\","
+ "\"date\":\"BIGGER\""
+ "},"
+ "\"check_vertex\":false,"
+ "\"create_if_not_exist\":true"
+ "}", outVId, inVId);
edge = String.format("{" +
"\"edges\":[" +
"{" +
"\"label\":\"knows\"," +
"\"outV\":\"%s\"," +
"\"outVLabel\":\"person\"," +
"\"inV\":\"%s\"," +
"\"inVLabel\":\"person\"," +
"\"properties\":{" +
"\"weight\":0.2," +
"\"date\":\"2014-02-20\"" +
"}" +
"}" +
"]," +
"\"update_strategies\":{" +
"\"weight\":\"SUM\"," +
"\"date\":\"BIGGER\"" +
"}," +
"\"check_vertex\":false," +
"\"create_if_not_exist\":true" +
"}", outVId, inVId);
r = client().put(path, "batch", edge, ImmutableMap.of());
// Add a new edge when sortkey value has changed
content = assertResponseStatus(200, r);
Expand All @@ -143,16 +143,16 @@ public void testGet() throws IOException {
String outVId = getVertexId("person", "name", "peter");
String inVId = getVertexId("software", "name", "lop");

String edge = String.format("{"
+ "\"label\": \"created\","
+ "\"outVLabel\": \"person\","
+ "\"inVLabel\": \"software\","
+ "\"outV\": \"%s\","
+ "\"inV\": \"%s\","
+ "\"properties\":{"
+ "\"date\": \"20170324\","
+ "\"weight\": 0.5}"
+ "}", outVId, inVId);
String edge = String.format("{" +
"\"label\": \"created\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"properties\":{" +
"\"date\": \"20170324\"," +
"\"weight\": 0.5}" +
"}", outVId, inVId);
Response r = client().post(path, edge);
String content = assertResponseStatus(201, r);

Expand All @@ -166,16 +166,16 @@ public void testList() throws IOException {
String outVId = getVertexId("person", "name", "peter");
String inVId = getVertexId("software", "name", "lop");

String edge = String.format("{"
+ "\"label\": \"created\","
+ "\"outVLabel\": \"person\","
+ "\"inVLabel\": \"software\","
+ "\"outV\": \"%s\","
+ "\"inV\": \"%s\","
+ "\"properties\":{"
+ "\"date\": \"20170324\","
+ "\"weight\": 0.5}"
+ "}", outVId, inVId);
String edge = String.format("{" +
"\"label\": \"created\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"properties\":{" +
"\"date\": \"20170324\"," +
"\"weight\": 0.5}" +
"}", outVId, inVId);
Response r = client().post(path, edge);
assertResponseStatus(201, r);

Expand All @@ -188,16 +188,16 @@ public void testDelete() throws IOException {
String outVId = getVertexId("person", "name", "peter");
String inVId = getVertexId("software", "name", "lop");

String edge = String.format("{"
+ "\"label\": \"created\","
+ "\"outVLabel\": \"person\","
+ "\"inVLabel\": \"software\","
+ "\"outV\": \"%s\","
+ "\"inV\": \"%s\","
+ "\"properties\":{"
+ "\"date\": \"20170324\","
+ "\"weight\": 0.5}"
+ "}", outVId, inVId);
String edge = String.format("{" +
"\"label\": \"created\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"properties\":{" +
"\"date\": \"20170324\"," +
"\"weight\": 0.5}" +
"}", outVId, inVId);
Response r = client().post(path, edge);
String content = assertResponseStatus(201, r);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,58 +39,58 @@ public void prepareSchema() {

@Test
public void testCreate() {
String edgeLabel = "{"
+ "\"name\": \"created\","
+ "\"source_label\": \"person\","
+ "\"target_label\": \"software\","
+ "\"frequency\": \"SINGLE\","
+ "\"properties\":[\"date\", \"city\"],"
+ "\"nullable_keys\":[\"city\"],"
+ "\"sort_keys\":[]"
+ "}";
String edgeLabel = "{" +
"\"name\": \"created\"," +
"\"source_label\": \"person\"," +
"\"target_label\": \"software\"," +
"\"frequency\": \"SINGLE\"," +
"\"properties\":[\"date\", \"city\"]," +
"\"nullable_keys\":[\"city\"]," +
"\"sort_keys\":[]" +
"}";
Response r = client().post(path, edgeLabel);
assertResponseStatus(201, r);
}

@Test
public void testAppend() {
String edgeLabel = "{"
+ "\"name\": \"created\","
+ "\"source_label\": \"person\","
+ "\"target_label\": \"software\","
+ "\"frequency\": \"SINGLE\","
+ "\"properties\":[\"date\", \"city\"],"
+ "\"nullable_keys\":[\"city\"],"
+ "\"sort_keys\":[]"
+ "}";
String edgeLabel = "{" +
"\"name\": \"created\"," +
"\"source_label\": \"person\"," +
"\"target_label\": \"software\"," +
"\"frequency\": \"SINGLE\"," +
"\"properties\":[\"date\", \"city\"]," +
"\"nullable_keys\":[\"city\"]," +
"\"sort_keys\":[]" +
"}";
Response r = client().post(path, edgeLabel);
assertResponseStatus(201, r);

edgeLabel = "{"
+ "\"name\": \"created\","
+ "\"source_label\": null,"
+ "\"target_label\": null,"
+ "\"frequency\": \"DEFAULT\","
+ "\"properties\":[\"lang\"],"
+ "\"nullable_keys\":[\"lang\"],"
+ "\"sort_keys\":[]"
+ "}";
edgeLabel = "{" +
"\"name\": \"created\"," +
"\"source_label\": null," +
"\"target_label\": null," +
"\"frequency\": \"DEFAULT\"," +
"\"properties\":[\"lang\"]," +
"\"nullable_keys\":[\"lang\"]," +
"\"sort_keys\":[]" +
"}";
Map<String, Object> params = ImmutableMap.of("action", "append");
r = client().put(path, "created", edgeLabel, params);
assertResponseStatus(200, r);
}

@Test
public void testGet() {
String edgeLabel = "{"
+ "\"name\": \"created\","
+ "\"source_label\": \"person\","
+ "\"target_label\": \"software\","
+ "\"frequency\": \"SINGLE\","
+ "\"properties\":[\"date\", \"city\"],"
+ "\"nullable_keys\":[\"city\"],"
+ "\"sort_keys\":[]"
+ "}";
String edgeLabel = "{" +
"\"name\": \"created\"," +
"\"source_label\": \"person\"," +
"\"target_label\": \"software\"," +
"\"frequency\": \"SINGLE\"," +
"\"properties\":[\"date\", \"city\"]," +
"\"nullable_keys\":[\"city\"]," +
"\"sort_keys\":[]" +
"}";
Response r = client().post(path, edgeLabel);
assertResponseStatus(201, r);

Expand All @@ -101,15 +101,15 @@ public void testGet() {

@Test
public void testList() {
String edgeLabel = "{"
+ "\"name\": \"created\","
+ "\"source_label\": \"person\","
+ "\"target_label\": \"software\","
+ "\"frequency\": \"SINGLE\","
+ "\"properties\":[\"date\", \"city\"],"
+ "\"nullable_keys\":[\"city\"],"
+ "\"sort_keys\":[]"
+ "}";
String edgeLabel = "{" +
"\"name\": \"created\"," +
"\"source_label\": \"person\"," +
"\"target_label\": \"software\"," +
"\"frequency\": \"SINGLE\"," +
"\"properties\":[\"date\", \"city\"]," +
"\"nullable_keys\":[\"city\"]," +
"\"sort_keys\":[]" +
"}";
Response r = client().post(path, edgeLabel);
assertResponseStatus(201, r);

Expand All @@ -119,15 +119,15 @@ public void testList() {

@Test
public void testDelete() {
String edgeLabel = "{"
+ "\"name\": \"created\","
+ "\"source_label\": \"person\","
+ "\"target_label\": \"software\","
+ "\"frequency\": \"SINGLE\","
+ "\"properties\":[\"date\", \"city\"],"
+ "\"nullable_keys\":[\"city\"],"
+ "\"sort_keys\":[]"
+ "}";
String edgeLabel = "{" +
"\"name\": \"created\"," +
"\"source_label\": \"person\"," +
"\"target_label\": \"software\"," +
"\"frequency\": \"SINGLE\"," +
"\"properties\":[\"date\", \"city\"]," +
"\"nullable_keys\":[\"city\"]," +
"\"sort_keys\":[]" +
"}";
Response r = client().post(path, edgeLabel);
assertResponseStatus(201, r);

Expand Down
Loading

0 comments on commit 2d25938

Please sign in to comment.