use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcListTest method shouldToJsonArrayCreatedDtoArray.
@Test
public void shouldToJsonArrayCreatedDtoArray() 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 expected = jsonFactory.createArray();
JsonValue parse = jsonFactory.parse(dto.toString());
expected.set(0, parse);
JsonRpcList jsonRpcList = new JsonRpcList(singletonList(dto), jsonFactory, dtoFactory);
JsonArray actual = jsonRpcList.toJsonArray();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcListTest method shouldParseDtoArray.
@Test
public void shouldParseDtoArray() 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);
Dto actual = jsonRpcList.get(0, Dto.class);
assertEquals(expected.getParameter(), actual.getParameter());
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfNumber.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfNumber() throws Exception {
Double value = 0D;
JsonArray expected = jsonFactory.createArray();
expected.set(0, value);
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(value), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue 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.JsonValue 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));
}
Aggregations