use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayParsedDtoArray.
@Test
public void shouldToJsonArrayParsedDtoArray() 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);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(array.jsEquals(actual));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringCreatedBooleanArray.
@Test
public void shouldToStringCreatedBooleanArray() throws Exception {
JsonArray array = jsonFactory.createArray();
array.set(0, false);
JsonRpcList jsonRpcList = new JsonRpcList(singletonList(false), jsonFactory, dtoFactory);
assertEquals(array.toJson(), jsonRpcList.toString());
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToStringifiedListParsedStringArray.
@Test
public void shouldToStringifiedListParsedStringArray() throws Exception {
String expected = "a";
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
List<String> actual = jsonRpcList.toStringifiedList();
assertEquals("\"a\"", actual.get(0));
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldToListParsedStringArray.
@Test
public void shouldToListParsedStringArray() throws Exception {
String expected = "a";
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
List<String> actual = jsonRpcList.toList(String.class);
assertEquals(singletonList(expected), actual);
}
use of elemental.json.JsonArray in project che by eclipse.
the class JsonRpcListTest method shouldParseNumberArray.
@Test
public void shouldParseNumberArray() throws Exception {
Double expected = 0D;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
String message = array.toJson();
JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
Double actual = jsonRpcList.get(0, Double.class);
assertEquals(expected, actual);
}
Aggregations