use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithoutIdAndWithParams.
@Test
public void shouldToStringWhenPassStringParamsWithoutIdAndWithParams() {
when(params.emptyOrAbsent()).thenReturn(false);
JsonObject expected = request;
expected.remove("id");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("method", params, jsonFactory);
JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenParseStringParamsWithoutIdAndWithoutParams.
@Test
public void shouldToStringWhenParseStringParamsWithoutIdAndWithoutParams() {
when(params.emptyOrAbsent()).thenReturn(false);
JsonObject expected = request;
expected.remove("params");
expected.remove("id");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toJson(), jsonFactory, jsonRpcFactory);
JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenParseStringParamsWithIdAndWithParams.
@Test
public void shouldToStringWhenParseStringParamsWithIdAndWithParams() {
when(params.emptyOrAbsent()).thenReturn(false);
JsonObject expected = request;
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toJson(), jsonFactory, jsonRpcFactory);
JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenParseStringParamsWithIdAndWithoutParams.
@Test
public void shouldToStringWhenParseStringParamsWithIdAndWithoutParams() {
when(params.emptyOrAbsent()).thenReturn(false);
JsonObject expected = request;
expected.remove("params");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toJson(), jsonFactory, jsonRpcFactory);
JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParams method toJsonValue.
public JsonValue toJsonValue() {
if (params != null) {
return params;
} else {
JsonArray array = jsonFactory.createArray();
for (int i = 0; i < paramsList.size(); i++) {
JsonValue value = paramsList.get(i);
array.set(i, value);
}
return array;
}
}
Aggregations