Search in sources :

Example 56 with JsonValue

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

the class JsonRpcListTest method shouldParseDtoArray.

@Test
public void shouldParseDtoArray() throws Exception {
    Dto expected = mock(Dto.class);
    when(expected.toString()).thenReturn(DTO);
    when(expected.getParameter()).thenReturn("value");
    when(dtoFactory.createDtoFromJson(DTO, Dto.class)).thenReturn(expected);
    JsonValue parse = jsonFactory.parse(DTO);
    JsonArray array = jsonFactory.createArray();
    array.set(0, parse);
    String message = array.toJson();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
    Dto actual = jsonRpcList.get(0, Dto.class);
    assertEquals(expected.getParameter(), actual.getParameter());
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 57 with JsonValue

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

the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsAListOfNumber.

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

Example 58 with JsonValue

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

the class JsonRpcResultTest method shouldToJsonValueWhenParsingStringWithResultAsAListOfNumber.

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

Example 59 with JsonValue

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

the class JsonRpcParamsTest method shouldToJsonValueForParsedListDtoParams.

@Test
public void shouldToJsonValueForParsedListDtoParams() throws Exception {
    JsonArray array = jsonFactory.createArray();
    JsonObject jsonObject = jsonFactory.parse(DTO_JSON);
    array.set(0, jsonObject);
    JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + DTO_JSON + "]", jsonFactory, dtoFactory);
    JsonValue jsonValue = jsonRpcParams.toJsonValue();
    assertEquals(array.toJson(), jsonValue.toJson());
    assertTrue(array.jsEquals(jsonValue));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 60 with JsonValue

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

the class JsonRpcParamsTest method shouldToJsonValueForParsedSingleDtoParams.

@Test
public void shouldToJsonValueForParsedSingleDtoParams() throws Exception {
    JsonString expected = jsonFactory.create(DTO_JSON);
    JsonRpcParams jsonRpcParams = new JsonRpcParams(DTO_JSON, dtoFactory, jsonFactory);
    JsonValue actual = jsonRpcParams.toJsonValue();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonValue(elemental.json.JsonValue) JsonString(elemental.json.JsonString) 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