Search in sources :

Example 1 with JsonNumber

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

Example 2 with JsonNumber

use of elemental.json.JsonNumber in project che by eclipse.

the class JsonRpcResultTest method shouldToStringWhenParsingStringWithResultAsASingleNumber.

@Test
public void shouldToStringWhenParsingStringWithResultAsASingleNumber() throws Exception {
    Double expected = 0D;
    JsonNumber string = jsonFactory.create(expected);
    JsonRpcResult jsonRpcResult = new JsonRpcResult(string.toJson(), jsonFactory, dtoFactory);
    String actual = jsonRpcResult.toString();
    assertEquals(expected, Double.valueOf(actual));
}
Also used : JsonNumber(elemental.json.JsonNumber) JsonString(elemental.json.JsonString) Test(org.junit.Test)

Example 3 with JsonNumber

use of elemental.json.JsonNumber in project che by eclipse.

the class JsonRpcResultTest method shouldGetAsListOfNumberWhenParsingStringWithResultAsListOfNumber.

@Test
public void shouldGetAsListOfNumberWhenParsingStringWithResultAsListOfNumber() throws Exception {
    Double expected = 0D;
    JsonNumber string = jsonFactory.create(expected);
    JsonArray array = jsonFactory.createArray();
    array.set(0, string);
    JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toJson(), jsonFactory, dtoFactory);
    List<Double> actual = jsonRpcResult.getAsListOf(Double.class);
    assertEquals(expected, actual.iterator().next());
}
Also used : JsonArray(elemental.json.JsonArray) JsonNumber(elemental.json.JsonNumber) Test(org.junit.Test)

Example 4 with JsonNumber

use of elemental.json.JsonNumber in project che by eclipse.

the class JsonRpcResultTest method shouldGetAsListOfNumberWhenPassingParametersWithResultAsListOfNumber.

@Test
public void shouldGetAsListOfNumberWhenPassingParametersWithResultAsListOfNumber() throws Exception {
    Double expected = 0D;
    JsonNumber string = jsonFactory.create(expected);
    JsonArray array = jsonFactory.createArray();
    array.set(0, string);
    JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(expected), jsonFactory, dtoFactory);
    List<Double> actual = jsonRpcResult.getAsListOf(Double.class);
    assertEquals(expected, actual.iterator().next());
}
Also used : JsonArray(elemental.json.JsonArray) JsonNumber(elemental.json.JsonNumber) Test(org.junit.Test)

Example 5 with JsonNumber

use of elemental.json.JsonNumber in project che by eclipse.

the class JsonRpcResultTest method shouldToStringWhenParsingStringWithResultAsAListOfNumber.

@Test
public void shouldToStringWhenParsingStringWithResultAsAListOfNumber() throws Exception {
    JsonNumber number = jsonFactory.create(0D);
    JsonArray array = jsonFactory.createArray();
    array.set(0, number);
    String expected = array.toJson();
    JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toJson(), 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