use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcErrorTest method shouldToJsonObjectProperly.
@Test
public void shouldToJsonObjectProperly() {
JsonRpcError real = new JsonRpcError(ERROR_JSON, jsonParser);
JsonElement expected = jsonParser.parse(ERROR_JSON);
assertTrue(real.toJsonObject().equals(expected));
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto() throws Exception {
JsonArray expected = new JsonArray();
JsonObject value = jsonParser.parse(dto.toString()).getAsJsonObject();
expected.add(value);
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(dto), jsonParser);
JsonElement actual = jsonRpcResult.toJsonElement();
assertEquals(expected, actual);
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsASingleString.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsASingleString() throws Exception {
JsonPrimitive expected = new JsonPrimitive("a");
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 JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfNumber.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfNumber() throws Exception {
Double value = 0D;
JsonPrimitive primitive = new JsonPrimitive(value);
JsonArray expected = new JsonArray();
expected.add(primitive);
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(value), jsonParser);
JsonElement actual = jsonRpcResult.toJsonElement();
assertEquals(expected, (actual));
}
use of com.google.gson.JsonElement in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedListDtoParams.
@Test
public void shouldToJsonForCreatedListDtoParams() throws Exception {
List<Dto> list = singletonList(dto);
JsonArray expected = new JsonArray();
JsonElement element = jsonParser.parse(dto.toString());
expected.add(element);
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonParser);
JsonElement actual = jsonRpcParams.toJsonElement();
assertEquals(expected, actual);
}
Aggregations