Search in sources :

Example 1 with JsonValue

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

the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithIdAndWithoutParams.

@Test
public void shouldToStringWhenPassStringParamsWithIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(true);
    JsonObject expected = request;
    expected.remove("params");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("0", "method", params, jsonFactory);
    JsonValue actual = jsonFactory.parse(jsonRpcRequest.toString());
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 2 with JsonValue

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

the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto.

@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsAListOfDto() throws Exception {
    JsonArray expected = jsonFactory.createArray();
    JsonObject value = jsonFactory.parse(dto.toString());
    expected.set(0, value);
    JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(dto), jsonFactory, dtoFactory);
    JsonValue actual = jsonRpcResult.toJsonValue();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 3 with JsonValue

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

the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsAListOfString.

@Test
public void shouldToJsonValueWhenParsingStringWithResultAsAListOfString() throws Exception {
    JsonString string = jsonFactory.create("a");
    JsonArray expected = jsonFactory.createArray();
    expected.set(0, string);
    JsonRpcResult jsonRpcResult = new JsonRpcResult(expected.toJson(), jsonFactory, dtoFactory);
    JsonValue actual = jsonRpcResult.toJsonValue();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) JsonString(elemental.json.JsonString) Test(org.junit.Test)

Example 4 with JsonValue

use of elemental.json.JsonValue 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 5 with JsonValue

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

the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsASingleDto.

@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsASingleDto() throws Exception {
    JsonObject expected = jsonFactory.parse(dto.toString());
    JsonRpcResult jsonRpcResult = new JsonRpcResult(dto, dtoFactory, jsonFactory);
    JsonValue actual = jsonRpcResult.toJsonValue();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonValue (elemental.json.JsonValue)126 Test (org.junit.Test)87 JsonObject (elemental.json.JsonObject)58 JsonArray (elemental.json.JsonArray)34 JsonString (elemental.json.JsonString)12 UI (com.vaadin.flow.component.UI)11 Element (com.vaadin.flow.dom.Element)10 Component (com.vaadin.flow.component.Component)9 Serializable (java.io.Serializable)8 ArrayList (java.util.ArrayList)8 StateNode (com.vaadin.client.flow.StateNode)6 SerializableConsumer (com.vaadin.flow.function.SerializableConsumer)6 StateNode (com.vaadin.flow.internal.StateNode)6 Json (elemental.json.Json)6 HashMap (java.util.HashMap)6 List (java.util.List)6 Assert (org.junit.Assert)6 MapProperty (com.vaadin.client.flow.nodefeature.MapProperty)5 MockVaadinSession (com.vaadin.flow.server.MockVaadinSession)5 Dependency (com.vaadin.flow.shared.ui.Dependency)5