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);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithParams.
@Test
public void shouldToStringWhenPassStringParamsWithIdAndWithParams() {
when(params.emptyOrAbsent()).thenReturn(false);
JsonObject expected = request;
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 JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsASingleNumber.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsASingleNumber() throws Exception {
JsonPrimitive expected = new JsonPrimitive(0D);
JsonRpcResult jsonRpcResult = new JsonRpcResult(expected.toString(), jsonParser);
JsonElement actual = jsonRpcResult.toJsonElement();
assertEquals(expected, actual);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedSingleDoubleParams.
@Test
public void shouldToJsonForCreatedSingleDoubleParams() throws Exception {
Double expected = 0D;
JsonRpcParams jsonRpcParams = new JsonRpcParams(expected, jsonParser);
JsonElement actual = jsonRpcParams.toJsonElement();
assertEquals(expected, Double.valueOf(actual.toString()));
}
Aggregations