Search in sources :

Example 76 with JsonValue

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

Example 77 with JsonValue

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

Example 78 with JsonValue

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

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

Example 80 with JsonValue

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));
}
Also used : JsArray(com.vaadin.client.flow.collection.JsArray) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Aggregations

JsonValue (elemental.json.JsonValue)102 Test (org.junit.Test)76 JsonObject (elemental.json.JsonObject)46 JsonArray (elemental.json.JsonArray)31 JsonString (elemental.json.JsonString)11 JsonNull (elemental.json.JsonNull)7 Element (com.vaadin.flow.dom.Element)5 Matchers.anyString (org.mockito.Matchers.anyString)5 UI (com.vaadin.flow.component.UI)4 StateNode (com.vaadin.flow.internal.StateNode)4 JsonNumber (elemental.json.JsonNumber)4 StateNodeTest (com.vaadin.flow.internal.StateNodeTest)3 ArrayList (java.util.ArrayList)3 StateNode (com.vaadin.client.flow.StateNode)2 MapProperty (com.vaadin.client.flow.nodefeature.MapProperty)2 JsonSerializable (com.vaadin.flow.component.JsonSerializable)2 StateTree (com.vaadin.flow.internal.StateTree)2 AbstractNodeFeatureTest (com.vaadin.flow.internal.nodefeature.AbstractNodeFeatureTest)2 ElementData (com.vaadin.flow.internal.nodefeature.ElementData)2 Element (elemental.dom.Element)2