use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithoutParams.
@Test
public void shouldToStringWhenPassStringParamsWithIdAndWithoutParams() {
when(params.emptyOrAbsent()).thenReturn(true);
JsonObject expected = request;
expected.remove("params");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("0", "method", params, jsonParser);
JsonElement actual = jsonParser.parse(jsonRpcRequest.toString());
assertEquals(expected, actual);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcResponseTest method shouldToStringWhenPassingParametersWithError.
@Test
public void shouldToStringWhenPassingParametersWithError() throws Exception {
JsonObject expected = response;
expected.remove("result");
JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(ID, null, error);
JsonElement actual = jsonParser.parse(jsonRpcResponse.toString());
assertEquals(expected, actual);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcResponseTest method shouldToStringWhenParsingStringWithError.
@Test
public void shouldToStringWhenParsingStringWithError() throws Exception {
JsonObject expected = response;
expected.remove("result");
JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(expected.toString(), jsonParser);
JsonElement actual = jsonParser.parse(jsonRpcResponse.toString());
assertEquals(expected, actual);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsASingleString.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsASingleString() throws Exception {
String value = "a";
JsonPrimitive expected = new JsonPrimitive(value);
JsonRpcResult jsonRpcResult = new JsonRpcResult(value, jsonParser);
JsonElement actual = jsonRpcResult.toJsonElement();
assertEquals(expected, actual);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedListDoubleParams.
@Test
public void shouldToJsonForCreatedListDoubleParams() throws Exception {
double value = 0D;
List<Double> list = singletonList(value);
JsonArray expected = new JsonArray();
expected.add(new JsonPrimitive(value));
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonParser);
JsonElement actual = jsonRpcParams.toJsonElement();
assertEquals(expected, actual);
}
Aggregations