use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcErrorTest method shouldToStringProperly.
@Test
public void shouldToStringProperly() {
JsonRpcError real = new JsonRpcError(ERROR_JSON, jsonFactory);
JsonValue expected = jsonFactory.parse(ERROR_JSON);
assertEquals(real.toString(), expected.toJson());
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcListTest method shouldToStringArrayParsedDtoArray.
@Test
public void shouldToStringArrayParsedDtoArray() 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);
String actual = jsonRpcList.toString();
assertEquals(message, actual);
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedListBooleanParams.
@Test
public void shouldToJsonValueForParsedListBooleanParams() throws Exception {
Boolean expected = false;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + expected + "]", jsonFactory, dtoFactory);
JsonValue jsonValue = jsonRpcParams.toJsonValue();
assertTrue(array.jsEquals(jsonValue));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedSingleDtoParams.
@Test
public void shouldToJsonForCreatedSingleDtoParams() throws Exception {
JsonValue expected = jsonFactory.parse(dto.toString());
JsonRpcParams jsonRpcParams = new JsonRpcParams(dto, dtoFactory, jsonFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcListTest method shouldToListParsedDtoArray.
@Test
public void shouldToListParsedDtoArray() 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<Dto> actual = jsonRpcList.toList(Dto.class);
assertEquals(singletonList(expected), actual);
}
Aggregations