use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsASingleDto.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsASingleDto() throws Exception {
JsonObject value = jsonFactory.parse(dto.toString());
JsonRpcResult jsonRpcResult = new JsonRpcResult(dto.toString(), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(value.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfString.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfString() throws Exception {
String value = "a";
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 shouldToJsonValueWhenParsingStringWithResultAsASingleString.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsASingleString() throws Exception {
JsonString expected = jsonFactory.create("a");
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 shouldToJsonValueForParsedSingleDoubleParams.
@Test
public void shouldToJsonValueForParsedSingleDoubleParams() throws Exception {
Double expected = 0D;
JsonRpcParams jsonRpcParams = new JsonRpcParams(expected.toString(), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertEquals(expected, Double.valueOf(actual.toJson()));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithParams.
@Test
public void shouldToStringWhenPassStringParamsWithIdAndWithParams() {
when(params.emptyOrAbsent()).thenReturn(false);
JsonObject expected = request;
JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("0", "method", params, jsonFactory);
JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
assertTrue(expected.jsEquals(actual));
}
Aggregations