use of com.google.gson.JsonPrimitive 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.JsonPrimitive in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsListOfNumberWhenPassingParametersWithResultAsListOfNumber.
@Test
public void shouldGetAsListOfNumberWhenPassingParametersWithResultAsListOfNumber() throws Exception {
Double expected = 0D;
JsonPrimitive primitive = new JsonPrimitive(expected);
JsonArray array = new JsonArray();
array.add(primitive);
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(expected), jsonParser);
List<Double> actual = jsonRpcResult.getAsListOf(Double.class);
assertEquals(expected, actual.iterator().next());
}
use of com.google.gson.JsonPrimitive 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.JsonPrimitive in project che by eclipse.
the class JsonRpcParamsTest method shouldToStringCreatedListStringParams.
@Test
public void shouldToStringCreatedListStringParams() throws Exception {
String value = "value";
JsonArray array = new JsonArray();
array.add(new JsonPrimitive(value));
String expected = array.toString();
JsonRpcParams jsonRpcParams = new JsonRpcParams(singletonList(value), jsonParser);
String actual = jsonRpcParams.toString();
assertEquals(expected, actual);
}
use of com.google.gson.JsonPrimitive in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedListDoubleParams.
@Test
public void shouldToJsonValueForParsedListDoubleParams() throws Exception {
Double expected = 0D;
JsonArray array = new JsonArray();
array.add(new JsonPrimitive(expected));
JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + expected + "]", jsonParser);
JsonElement jsonValue = jsonRpcParams.toJsonElement();
assertEquals(array, jsonValue);
}
Aggregations