use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringCreatedDtoArray.
@Test
public void shouldToStringCreatedDtoArray() throws Exception {
Dto dto = mock(Dto.class);
when(dto.toString()).thenReturn(DTO);
when(dto.getParameter()).thenReturn("value");
when(dtoFactory.createDtoFromJson(DTO, Dto.class)).thenReturn(dto);
JsonArray array = jsonFactory.createArray();
JsonValue parse = jsonFactory.parse(dto.toString());
array.set(0, parse);
JsonRpcList jsonRpcList = new JsonRpcList(singletonList(dto), jsonFactory, dtoFactory);
assertEquals(array.toJson(), jsonRpcList.toString());
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToListParsedNumberArray.
@Test
public void shouldToListParsedNumberArray() throws Exception {
Double expected = 0D;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
List<Double> actual = jsonRpcList.toList(Double.class);
assertEquals(singletonList(expected), actual);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayCreatedBooleanArray.
@Test
public void shouldToJsonArrayCreatedBooleanArray() throws Exception {
JsonArray expected = jsonFactory.createArray();
expected.set(0, false);
JsonRpcList jsonRpcList = new JsonRpcList(singletonList(false), jsonFactory, dtoFactory);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedListDtoParams.
@Test
public void shouldToJsonForCreatedListDtoParams() throws Exception {
List<Dto> list = singletonList(dto);
JsonArray expected = jsonFactory.createArray();
JsonValue jsonValue = jsonFactory.parse(dto.toString());
expected.set(0, jsonValue);
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonFactory, dtoFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcParamsTest method shouldToStringForParsedListStringParams.
@Test
public void shouldToStringForParsedListStringParams() throws Exception {
String value = "value";
JsonArray expected = jsonFactory.createArray();
expected.set(0, value);
JsonRpcParams jsonRpcParams = new JsonRpcParams("[\"" + value + "\"]", jsonFactory, dtoFactory);
String actual = jsonRpcParams.toString();
assertEquals(expected.toJson(), actual);
}
Aggregations