use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringifiedListParsedDtoArray.
@Test
public void shouldToStringifiedListParsedDtoArray() 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);
List<String> actual = jsonRpcList.toStringifiedList();
assertEquals(expected.toString(), actual.iterator().next());
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringArrayParsedBooleanArray.
@Test
public void shouldToStringArrayParsedBooleanArray() throws Exception {
Boolean expected = false;
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 shouldToJsonArrayParsedStringArray.
@Test
public void shouldToJsonArrayParsedStringArray() throws Exception {
String expected = "a";
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(array.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToStringCreatedListDtoParams.
@Test
public void shouldToStringCreatedListDtoParams() throws Exception {
List<Dto> list = singletonList(dto);
JsonArray jsonArray = jsonFactory.createArray();
JsonValue jsonValue = jsonFactory.parse(dto.toString());
jsonArray.set(0, jsonValue);
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 JsonRpcParamsTest method shouldToStringForParsedListDtoParams.
@Test
public void shouldToStringForParsedListDtoParams() throws Exception {
JsonArray array = jsonFactory.createArray();
JsonObject jsonObject = jsonFactory.parse(DTO_JSON);
array.set(0, jsonObject);
String expected = array.toJson();
JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + DTO_JSON + "]", jsonFactory, dtoFactory);
String actual = jsonRpcParams.toString();
assertEquals(expected, actual);
}
Aggregations