Search in sources :

Example 66 with JsonValue

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

the class JsonRpcParamsTest method shouldToJsonForCreatedListDoubleParams.

@Test
public void shouldToJsonForCreatedListDoubleParams() throws Exception {
    double value = 0D;
    List<Double> 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 67 with JsonValue

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

the class JsonRpcResponseTest method shouldToStringWhenPassingParametersWithError.

@Test
public void shouldToStringWhenPassingParametersWithError() throws Exception {
    JsonObject expected = response;
    expected.remove("result");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(ID, null, error, jsonFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcResponse.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 68 with JsonValue

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

the class JsonRpcResponseTest method shouldToStringWhenParsingStringWithError.

@Test
public void shouldToStringWhenParsingStringWithError() throws Exception {
    JsonObject expected = response;
    expected.remove("result");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(expected.toJson(), jsonFactory, dtoFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcResponse.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 69 with JsonValue

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

the class JsonRpcResponseTest method shouldToStringWhenPassingParametersWithResult.

@Test
public void shouldToStringWhenPassingParametersWithResult() throws Exception {
    JsonObject expected = response;
    expected.remove("error");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(ID, result, null, jsonFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcResponse.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 70 with JsonValue

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

the class JsonRpcResponseTest method shouldToStringWhenParsingStringWithResult.

@Test
public void shouldToStringWhenParsingStringWithResult() throws Exception {
    JsonObject expected = response;
    expected.remove("error");
    JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(expected.toJson(), jsonFactory, dtoFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcResponse.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) 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