use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithoutParams.
@Test
public void shouldToStringWhenPassStringParamsWithIdAndWithoutParams() {
when(params.emptyOrAbsent()).thenReturn(true);
JsonObject expected = request;
expected.remove("params");
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("0", "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 JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto() throws Exception {
JsonArray expected = jsonFactory.createArray();
JsonObject value = jsonFactory.parse(dto.toString());
expected.set(0, value);
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(dto), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsAListOfString.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsAListOfString() throws Exception {
JsonString string = jsonFactory.create("a");
JsonArray expected = jsonFactory.createArray();
expected.set(0, string);
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 JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsASingleNumber.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsASingleNumber() throws Exception {
Double number = 0D;
JsonNumber expected = jsonFactory.create(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 JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsASingleDto.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsASingleDto() throws Exception {
JsonObject expected = jsonFactory.parse(dto.toString());
JsonRpcResult jsonRpcResult = new JsonRpcResult(dto, dtoFactory, jsonFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
Aggregations