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);
}
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);
}
Aggregations