use of com.google.gson.JsonArray 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.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToStringForParsedListStringParams.
@Test
public void shouldToStringForParsedListStringParams() throws Exception {
String value = "value";
JsonArray array = new JsonArray();
array.add(new JsonPrimitive(value));
String expected = array.toString();
JsonRpcParams jsonRpcParams = new JsonRpcParams("[\"" + value + "\"]", jsonParser);
String actual = jsonRpcParams.toString();
assertEquals(expected, actual);
}
use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayParsedBooleanArray.
@Test
public void shouldToJsonArrayParsedBooleanArray() throws Exception {
Boolean expected = false;
JsonArray array = new JsonArray();
array.add(new JsonPrimitive(expected));
String message = array.toString();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonParser);
JsonArray actual = jsonRpcList.toJsonArray();
assertEquals(array, actual);
}
use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldParseNumberArray.
@Test
public void shouldParseNumberArray() throws Exception {
Double expected = 0D;
JsonArray array = new JsonArray();
array.add(new JsonPrimitive(expected));
String message = array.toString();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonParser);
Double actual = jsonRpcList.get(0, Double.class);
assertEquals(expected, actual);
}
use of com.google.gson.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayCreatedStringArray.
@Test
public void shouldToJsonArrayCreatedStringArray() throws Exception {
JsonArray expected = new JsonArray();
expected.add(new JsonPrimitive("a"));
JsonRpcList jsonRpcList = new JsonRpcList(singletonList("a"), jsonParser);
JsonArray actual = jsonRpcList.toJsonArray();
assertEquals(expected, actual);
}
Aggregations