Skip to content

Commit

Permalink
tiny fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imbajin committed Dec 5, 2023
1 parent 4f1622c commit a3b4423
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ protected String type() {
}

@SuppressWarnings("unchecked")
public Map<String, String> create(String name, String cloneGraphName,
String configText) {
public Map<String, String> create(String name, String cloneGraphName, String configText) {
this.client.checkApiVersion("0.67", "dynamic graph add");
RestHeaders headers = new RestHeaders().add(RestHeaders.CONTENT_TYPE, "text/plain");
Map<String, Object> params = null;
Expand Down Expand Up @@ -87,8 +86,8 @@ public void drop(String graph, String message) {
}

public void mode(String graph, GraphMode mode) {
// NOTE: Must provide id for PUT. If use "graph/mode", "/" will
// be encoded to "%2F". So use "mode" here although inaccurate.
// NOTE: Must provide id for PUT. If you use "graph/mode", "/" will
// be encoded to "%2F". So use "mode" here, although inaccurate.
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
}

Expand All @@ -109,16 +108,15 @@ public GraphMode mode(String graph) {

public void readMode(String graph, GraphReadMode readMode) {
this.client.checkApiVersion("0.59", "graph read mode");
// NOTE: Must provide id for PUT. If use "graph/graph_read_mode", "/"
// will be encoded to "%2F". So use "graph_read_mode" here although
// NOTE: Must provide id for PUT. If you use "graph/graph_read_mode", "/"
// will be encoded to "%2F". So use "graph_read_mode" here, although
// inaccurate.
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null, readMode);
}

public GraphReadMode readMode(String graph) {
this.client.checkApiVersion("0.59", "graph read mode");
RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
RestResult result = this.client.get(joinPath(this.path(), graph), GRAPH_READ_MODE);
@SuppressWarnings("unchecked")
Map<String, String> readMode = result.readObject(Map.class);
String value = readMode.get(GRAPH_READ_MODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void initManagers(RestClient client, String graph) {
private void checkServerApiVersion() {
VersionUtil.Version apiVersion = VersionUtil.Version.of(this.version.getApiVersion());
// TODO: find a way to keep the range of api version correct automatically
// 0.81 equals to the {latest_api_version} +10
// 0.81 equals to the {latest_api_version} +10
VersionUtil.check(apiVersion, "0.38", "0.81", "hugegraph-api in server");
this.client.apiVersion(apiVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ public class ServerException extends RuntimeException {

private static final long serialVersionUID = 6335623004322652358L;

private static final String[] EXCEPTION_KEYS = {"exception",
"Exception-Class"};
private static final String[] EXCEPTION_KEYS = {"exception", "Exception-Class"};
private static final String[] MESSAGE_KEYS = {"message"};
private static final String[] CAUSE_KEYS = {"cause", "exceptions"};
private static final String[] TRACE_KEYS = {"trace", "stackTrace"};


private int status = 0;
private String exception;
private String message;
Expand All @@ -54,7 +52,7 @@ public static ServerException fromResponse(okhttp3.Response response) {
exception.cause = (String) getByKeys(json, CAUSE_KEYS);
exception.trace = getByKeys(json, TRACE_KEYS);
} catch (Exception ignored) {
LOG.error("ServerException fromResponse excepiton");
LOG.error("ServerException fromResponse exception");
}

return exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ public class BaseClientTest {

private static HugeClient client;

protected static HugeClient open() {
client = HugeClient.builder(BASE_URL, GRAPH)
.configUser(USERNAME, PASSWORD)
.build();
return client;
protected static void open() {
client = HugeClient.builder(BASE_URL, GRAPH).configUser(USERNAME, PASSWORD).build();
}

@BeforeClass
Expand Down Expand Up @@ -125,8 +122,7 @@ public static MetricsManager metrics() {
return client.metrics();
}

protected static Object getVertexId(String label, String key,
String value) {
protected static Object getVertexId(String label, String key, String value) {
return getVertex(label, key, value).id();
}

Expand All @@ -148,23 +144,19 @@ protected static Edge getEdge(String label, String key, String value) {
return edges.get(0);
}

protected static void assertContains(List<PropertyKey> propertyKeys,
PropertyKey propertyKey) {
protected static void assertContains(List<PropertyKey> propertyKeys, PropertyKey propertyKey) {
Assert.assertTrue(Utils.contains(propertyKeys, propertyKey));
}

protected static void assertContains(List<VertexLabel> vertexLabels,
VertexLabel vertexLabel) {
protected static void assertContains(List<VertexLabel> vertexLabels, VertexLabel vertexLabel) {
Assert.assertTrue(Utils.contains(vertexLabels, vertexLabel));
}

protected static void assertContains(List<EdgeLabel> edgeLabels,
EdgeLabel edgeLabel) {
protected static void assertContains(List<EdgeLabel> edgeLabels, EdgeLabel edgeLabel) {
Assert.assertTrue(Utils.contains(edgeLabels, edgeLabel));
}

protected static void assertContains(List<IndexLabel> indexLabels,
IndexLabel indexLabel) {
protected static void assertContains(List<IndexLabel> indexLabels, IndexLabel indexLabel) {
Assert.assertTrue(Utils.contains(indexLabels, indexLabel));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@

public class EdgeTest extends BaseFuncTest {

private static void assertContains(List<Edge> edges, Object source,
String label, Object target,
Object... keyValues) {
private static void assertContains(List<Edge> edges, Object source, String label,
Object target, Object... keyValues) {
Map<String, Object> properties = Utils.asMap(keyValues);

Edge edge = new Edge(label);
Expand Down

0 comments on commit a3b4423

Please sign in to comment.