use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcParams method toJsonElement.
public JsonElement toJsonElement() {
if (params != null) {
return params;
}
JsonArray array = new JsonArray();
paramsList.forEach(array::add);
return array;
}
use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsListOfStringWhenParsingStringWithResultAsString.
@Test
public void shouldGetAsListOfStringWhenParsingStringWithResultAsString() throws Exception {
String expected = "a";
JsonPrimitive primitive = new JsonPrimitive(expected);
JsonArray array = new JsonArray();
array.add(primitive);
JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toString(), jsonParser);
List<String> actual = jsonRpcResult.getAsListOf(String.class);
assertEquals(expected, actual.iterator().next());
}
use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedListDoubleParams.
@Test
public void shouldToJsonForCreatedListDoubleParams() throws Exception {
double value = 0D;
List<Double> list = singletonList(value);
JsonArray expected = new JsonArray();
expected.add(new JsonPrimitive(value));
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonParser);
JsonElement actual = jsonRpcParams.toJsonElement();
assertEquals(expected, actual);
}
use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToStringCreatedListBooleanParams.
@Test
public void shouldToStringCreatedListBooleanParams() throws Exception {
Boolean value = false;
List<Boolean> list = singletonList(value);
JsonArray jsonArray = new JsonArray();
jsonArray.add(new JsonPrimitive(value));
String expected = jsonArray.toString();
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonParser);
String actual = jsonRpcParams.toString();
assertEquals(expected, actual);
}
use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayCreatedBooleanArray.
@Test
public void shouldToJsonArrayCreatedBooleanArray() throws Exception {
JsonArray expected = new JsonArray();
expected.add(new JsonPrimitive(false));
JsonRpcList jsonRpcList = new JsonRpcList(singletonList(false), jsonParser);
JsonArray actual = jsonRpcList.toJsonArray();
assertEquals(expected, actual);
}
Aggregations