use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams.
@Test
public void shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams() {
when(params.emptyOrAbsent()).thenReturn(true);
JsonObject expected = request;
expected.remove("params");
expected.remove("id");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("method", params, jsonFactory);
JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenParseStringParamsWithoutIdAndWithParams.
@Test
public void shouldToStringWhenParseStringParamsWithoutIdAndWithParams() {
when(params.emptyOrAbsent()).thenReturn(false);
JsonObject expected = request;
expected.remove("id");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toJson(), jsonFactory, jsonRpcFactory);
JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcListTest method shouldToStringifiedListParsedDtoArray.
@Test
public void shouldToStringifiedListParsedDtoArray() 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<String> actual = jsonRpcList.toStringifiedList();
assertEquals(expected.toString(), actual.iterator().next());
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToStringCreatedListDtoParams.
@Test
public void shouldToStringCreatedListDtoParams() throws Exception {
List<Dto> list = singletonList(dto);
JsonArray jsonArray = jsonFactory.createArray();
JsonValue jsonValue = jsonFactory.parse(dto.toString());
jsonArray.set(0, jsonValue);
String expected = jsonArray.toJson();
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonFactory, dtoFactory);
String actual = jsonRpcParams.toString();
assertEquals(expected, actual);
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedSingleBooleanParams.
@Test
public void shouldToJsonValueForParsedSingleBooleanParams() throws Exception {
Boolean expected = false;
JsonRpcParams jsonRpcParams = new JsonRpcParams(expected.toString(), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertEquals(expected, Boolean.valueOf(actual.toJson()));
}
Aggregations