Search in sources :

Example 6 with JsonNumber

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));
}
Also used : JsonArray(elemental.json.JsonArray) JsonNumber(elemental.json.JsonNumber) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 7 with JsonNumber

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);
}
Also used : JsonNumber(elemental.json.JsonNumber) Test(org.junit.Test)

Example 8 with JsonNumber

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));
}
Also used : JsonNumber(elemental.json.JsonNumber) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 9 with JsonNumber

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);
}
Also used : JsonArray(elemental.json.JsonArray) JsonNumber(elemental.json.JsonNumber) JsonString(elemental.json.JsonString) Test(org.junit.Test)

Aggregations

JsonNumber (elemental.json.JsonNumber)9 Test (org.junit.Test)9 JsonArray (elemental.json.JsonArray)5 JsonString (elemental.json.JsonString)3 JsonValue (elemental.json.JsonValue)3