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);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedSingleDtoParams.
@Test
public void shouldToJsonForCreatedSingleDtoParams() throws Exception {
JsonObject expected = jsonParser.parse(dto.toString()).getAsJsonObject();
JsonRpcParams jsonRpcParams = new JsonRpcParams(dto, jsonParser);
JsonElement actual = jsonRpcParams.toJsonElement();
assertEquals(expected, actual);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams.
@Test
public void shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams() {
when(params.emptyOrAbsent()).thenReturn(true);
JsonObject expected = request;
expected.remove("params");
expected.remove("id");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("method", params, jsonParser);
JsonElement actual = jsonParser.parse(jsonRpcRequest.toString());
assertEquals(expected, actual);
}
Aggregations