use of elemental.json.JsonNumber in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsAListOfNumber.
@Test
public void shouldToJsonValueWhenParsingStringWithResultAsAListOfNumber() throws Exception {
JsonNumber number = jsonFactory.create(0D);
JsonArray expected = jsonFactory.createArray();
expected.set(0, number);
JsonRpcResult jsonRpcResult = new JsonRpcResult(expected.toJson(), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonNumber in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsNumberWhenParsingStringWithResultAsNumber.
// Number
@Test
public void shouldGetAsNumberWhenParsingStringWithResultAsNumber() throws Exception {
JsonNumber value = jsonFactory.create(0D);
Double expected = value.asNumber();
JsonRpcResult jsonRpcResult = new JsonRpcResult(value.toJson(), jsonFactory, dtoFactory);
Double actual = jsonRpcResult.getAs(Double.class);
assertEquals(expected, actual);
}
use of elemental.json.JsonNumber in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsASingleNumber.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsASingleNumber() throws Exception {
Double number = 0D;
JsonNumber expected = jsonFactory.create(number);
JsonRpcResult jsonRpcResult = new JsonRpcResult(number, dtoFactory, jsonFactory);
JsonValue actual = jsonRpcResult.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonNumber in project che by eclipse.
the class JsonRpcResultTest method shouldToStringWhenPassingParametersWithResultAsAListOfNumber.
@Test
public void shouldToStringWhenPassingParametersWithResultAsAListOfNumber() throws Exception {
Double value = 0D;
JsonNumber string = jsonFactory.create(value);
JsonArray array = jsonFactory.createArray();
array.set(0, string);
String expected = array.toJson();
JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(value), jsonFactory, dtoFactory);
String actual = jsonRpcResult.toString();
assertEquals(expected, actual);
}
Aggregations