use of elemental.json.JsonValue 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.JsonValue 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.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedSingleStringParams.
@Test
public void shouldToJsonValueForParsedSingleStringParams() throws Exception {
String expected = "\"value\"";
JsonRpcParams jsonRpcParams = new JsonRpcParams(expected, jsonFactory, dtoFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertEquals(expected, actual.toJson());
}
use of elemental.json.JsonValue 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.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedSingleStringParams.
@Test
public void shouldToJsonForCreatedSingleStringParams() throws Exception {
String value = "value";
String expected = "\"" + value + "\"";
JsonRpcParams jsonRpcParams = new JsonRpcParams(value, dtoFactory, jsonFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertEquals(expected, actual.toJson());
}
Aggregations