Skip to content

Commit

Permalink
chore: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxxoo committed Jun 8, 2021
1 parent 4227ce6 commit 3677e56
Show file tree
Hide file tree
Showing 26 changed files with 331 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,25 @@
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

import com.baidu.hugegraph.api.traversers.AllShortestPathsAPITest;
import com.baidu.hugegraph.api.traversers.CountAPITest;
import com.baidu.hugegraph.api.traversers.CrosspointsAPITest;
import com.baidu.hugegraph.api.traversers.CustomizedCrosspointsAPITest;
import com.baidu.hugegraph.api.traversers.EdgesAPITest;
import com.baidu.hugegraph.api.traversers.FusiformSimilarityAPITest;
import com.baidu.hugegraph.api.traversers.JaccardSimilarityAPITest;
import com.baidu.hugegraph.api.traversers.KneighborAPITest;
import com.baidu.hugegraph.api.traversers.KoutAPITest;
import com.baidu.hugegraph.api.traversers.MultiNodeShortestPathAPITest;
import com.baidu.hugegraph.api.traversers.NeighborRankAPITest;
import com.baidu.hugegraph.api.traversers.PathsAPITest;
import com.baidu.hugegraph.api.traversers.PersonalRankAPITest;
import com.baidu.hugegraph.api.traversers.RaysAPITest;
import com.baidu.hugegraph.dist.RegisterUtil;

@RunWith(Suite.class)
@Suite.SuiteClasses({
UserApiTest.class,
PropertyKeyApiTest.class,
VertexLabelApiTest.class,
EdgeLabelApiTest.class,
Expand All @@ -36,21 +51,6 @@
TaskApiTest.class,
GremlinApiTest.class,
MetricsApiTest.class,
UserApiTest.class,
AllShortestPathsAPITest.class,
CountAPITest.class,
CrosspointsAPITest.class,
CustomizedCrosspointsAPITest.class,
EdgesAPITest.class,
FusiformSimilarityAPITest.class,
JaccardSimilarityAPITest.class,
KneighborAPITest.class,
KoutAPITest.class,
MultiNodeShortestPathAPITest.class,
NeighborRankAPITest.class,
PathsAPITest.class,
PersonalRankAPITest.class,
RaysAPITest.class
})
public class ApiTestSuite {

Expand Down
135 changes: 68 additions & 67 deletions hugegraph-test/src/main/java/com/baidu/hugegraph/api/BaseApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static RestClient newClient() {
return new RestClient(BASE_URL);
}

static class RestClient {
public static class RestClient {

private Client client;
private WebTarget target;
Expand Down Expand Up @@ -134,15 +134,17 @@ public Response get(String path, String id) {

public Response get(String path, Map<String, Object> params) {
return this.get(path,
params.entrySet().stream()
params.entrySet()
.stream()
.map(entry -> new Pair<String, Object>(
entry.getKey(), entry.getValue()))
entry.getKey(), entry.getValue()))
.iterator());
}

public Response get(String path,
Iterator<Pair<String, Object>> params) {
class WrapWebTarget {

WebTarget target;

WrapWebTarget(WebTarget target) {
Expand Down Expand Up @@ -323,65 +325,68 @@ protected static void initIndexLabel() {
protected static void initEdge() {
String path = URL_PREFIX + GRAPH_EDGE + BATCH;
Map<String, String> ret = getAllName2VertexIds();
System.out.println(ret);
String markoId = ret.get("marko");
String peterId = ret.get("peter");
String joshId = ret.get("josh");
String vadasId = ret.get("vadas");
String rippleId = ret.get("ripple");

createAndAssert(path, "[" +
"{" +
"\"label\": \"knows\"," +
"\"outV\": \"" + markoId + "\"," +
"\"inV\": \"" + peterId + "\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"person\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"knows\"," +
"\"outV\": \"" + peterId + "\"," +
"\"inV\": \"" + joshId + "\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"person\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"knows\"," +
"\"outV\": \"" + joshId + "\"," +
"\"inV\": \"" + vadasId + "\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"person\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"created\"," +
"\"outV\": \"" + markoId + "\"," +
"\"inV\": \"" + rippleId + "\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"created\"," +
"\"outV\": \"" + peterId + "\"," +
"\"inV\": \"" + rippleId + "\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}" +
"]");
String body = String.format("[" +
"{" +
"\"label\": \"knows\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"person\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"knows\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"person\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"knows\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"person\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"created\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}," +
"{" +
"\"label\": \"created\"," +
"\"outV\": \"%s\"," +
"\"inV\": \"%s\"," +
"\"outVLabel\": \"person\"," +
"\"inVLabel\": \"software\"," +
"\"properties\": {" +
"\"date\": \"2021-01-01\"," +
"\"weight\":0.5}" +
"}" +
"]", markoId, peterId, peterId, joshId,
joshId, vadasId, markoId, rippleId,
peterId, rippleId);

createAndAssert(path, );

}

Expand Down Expand Up @@ -453,20 +458,18 @@ protected static Response createAndAssert(String path, String body) {
protected static Map<String, String> getAllName2VertexIds() {
Response r = client.get(URL_PREFIX + GRAPH_VERTEX);
String content = r.readEntity(String.class);
if (r.getStatus() != 200) {
throw new HugeException("Failed to get vertex id: %s", content);
}
assertResponseStatus(200, r);

@SuppressWarnings("rawtypes")
List<Map> list = readList(content, "vertices", Map.class);

return list.stream().filter(map -> map.get("properties") != null &&
((Map) map.get("properties"))
.get("name") != null)
return list.stream()
.filter(map -> map.get("properties") != null &&
((Map) map.get("properties"))
.get("name") != null)
.collect(
Collectors.toMap(map -> ((Map) map.get("properties"))
.get(
"name").toString(),
.get("name").toString(),
map -> map.get("id").toString()));
}

Expand All @@ -479,9 +482,7 @@ protected static String getVertexId(String label, String key, String value)
);
Response r = client.get(URL_PREFIX + GRAPH_VERTEX, params);
String content = r.readEntity(String.class);
if (r.getStatus() != 200) {
throw new HugeException("Failed to get vertex id: %s", content);
}
assertResponseStatus(200, r);

@SuppressWarnings("rawtypes")
List<Map> list = readList(content, "vertices", Map.class);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3677e56

Please sign in to comment.