use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayCreatedStringArray.
@Test
public void shouldToJsonArrayCreatedStringArray() throws Exception {
JsonArray expected = jsonFactory.createArray();
expected.set(0, "a");
JsonRpcList jsonRpcList = new JsonRpcList(singletonList("a"), jsonFactory, dtoFactory);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringArrayParsedStringArray.
@Test
public void shouldToStringArrayParsedStringArray() 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.toString();
assertEquals(message, actual);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringArrayParsedDtoArray.
@Test
public void shouldToStringArrayParsedDtoArray() throws Exception {
Dto expected = mock(Dto.class);
when(expected.toString()).thenReturn(DTO);
when(expected.getParameter()).thenReturn("value");
when(dtoFactory.createDtoFromJson(DTO, Dto.class)).thenReturn(expected);
JsonValue parse = jsonFactory.parse(DTO);
JsonArray array = jsonFactory.createArray();
array.set(0, parse);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
String actual = jsonRpcList.toString();
assertEquals(message, actual);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToListParsedBooleanArray.
@Test
public void shouldToListParsedBooleanArray() throws Exception {
Boolean expected = false;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
List<Boolean> actual = jsonRpcList.toList(Boolean.class);
assertEquals(singletonList(expected), actual);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedListBooleanParams.
@Test
public void shouldToJsonValueForParsedListBooleanParams() throws Exception {
Boolean expected = false;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + expected + "]", jsonFactory, dtoFactory);
JsonValue jsonValue = jsonRpcParams.toJsonValue();
assertTrue(array.jsEquals(jsonValue));
}
Aggregations