use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsAListOfNumber.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsAListOfNumber() throws Exception {
JsonNumber number = jsonFactory.create(0D);
JsonArray expected = jsonFactory.createArray();
expected.set(0, number);
JsonRpcResult jsonRpcResult = new JsonRpcResult(expected.toJson(), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedListDtoParams.
@Test
public void shouldToJsonValueForParsedListDtoParams() throws Exception {
JsonArray array = jsonFactory.createArray();
JsonObject jsonObject = jsonFactory.parse(DTO_JSON);
array.set(0, jsonObject);
JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + DTO_JSON + "]", jsonFactory, dtoFactory);
JsonValue jsonValue = jsonRpcParams.toJsonValue();
assertEquals(array.toJson(), jsonValue.toJson());
assertTrue(array.jsEquals(jsonValue));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToStringCreatedListStringParams.
@Test
public void shouldToStringCreatedListStringParams() throws Exception {
String value = "value";
JsonArray expected = jsonFactory.createArray();
expected.set(0, value);
JsonRpcParams jsonRpcParams = new JsonRpcParams(singletonList(value), jsonFactory, dtoFactory);
String actual = jsonRpcParams.toString();
assertEquals(expected.toJson(), actual);
}
use of elemental.json.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 = jsonFactory.createArray();
jsonArray.set(0, value);
String expected = jsonArray.toJson();
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonFactory, dtoFactory);
String actual = jsonRpcParams.toString();
assertEquals(expected, actual);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldParseStringArray.
@Test
public void shouldParseStringArray() throws Exception {
String expected = "a";
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
String actual = jsonRpcList.get(0, String.class);
assertEquals(expected, actual);
}
Aggregations