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()));
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedListDtoParams.
@Test
public void shouldToJsonValueForParsedListDtoParams() throws Exception {
JsonArray array = new JsonArray();
JsonObject jsonObject = jsonParser.parse(DTO_JSON).getAsJsonObject();
array.add(jsonObject);
JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + DTO_JSON + "]", jsonParser);
JsonElement jsonValue = jsonRpcParams.toJsonElement();
assertEquals(array, jsonValue);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcErrorTest method shouldToStringProperly.
@Test
public void shouldToStringProperly() {
JsonRpcError real = new JsonRpcError(ERROR_JSON, jsonParser);
JsonElement expected = jsonParser.parse(ERROR_JSON);
assertEquals(real.toJsonObject(), expected);
}
Aggregations