use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedListStringParams.
@Test
public void shouldToJsonValueForParsedListStringParams() throws Exception {
String value = "value";
JsonArray expected = jsonFactory.createArray();
expected.set(0, value);
JsonRpcParams jsonRpcParams = new JsonRpcParams("[\"" + value + "\"]", jsonFactory, dtoFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedListStringParams.
@Test
public void shouldToJsonForCreatedListStringParams() throws Exception {
String value = "value";
JsonArray expected = jsonFactory.createArray();
expected.set(0, value);
JsonRpcParams jsonRpcParams = new JsonRpcParams(singletonList(value), jsonFactory, dtoFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonValueForParsedListDoubleParams.
@Test
public void shouldToJsonValueForParsedListDoubleParams() throws Exception {
Double expected = 0D;
JsonArray array = jsonFactory.createArray();
array.set(0, expected);
JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + expected + "]", jsonFactory, dtoFactory);
JsonValue jsonValue = jsonRpcParams.toJsonValue();
assertTrue(array.jsEquals(jsonValue));
}
use of elemental.json.JsonValue in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedListBooleanParams.
@Test
public void shouldToJsonForCreatedListBooleanParams() throws Exception {
Boolean value = false;
List<Boolean> list = singletonList(value);
JsonArray expected = jsonFactory.createArray();
expected.set(0, value);
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonFactory, dtoFactory);
JsonValue actual = jsonRpcParams.toJsonValue();
assertTrue(expected.jsEquals(actual));
}
use of elemental.json.JsonValue in project flow by vaadin.
the class ClientJsonCodecTest method decodeWithTypeInfo_array.
@Test
public void decodeWithTypeInfo_array() {
JsonValue json = JsonCodec.encodeWithTypeInfo(JsonUtils.createArray(Json.create("string"), Json.create(true)));
Object decoded = ClientJsonCodec.decodeWithTypeInfo(null, json);
Assert.assertTrue(decoded instanceof JsArray);
JsArray<?> decodedArray = (JsArray<?>) decoded;
Assert.assertEquals(2, decodedArray.length());
Assert.assertEquals("string", decodedArray.get(0));
Assert.assertEquals(Boolean.TRUE, decodedArray.get(1));
}
Aggregations