Search in sources :

Example 51 with JsonObject

use of elemental.json.JsonObject 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 52 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenParseStringParamsWithIdAndWithParams.

@Test
public void shouldToJsonObjectWhenParseStringParamsWithIdAndWithParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toJson(), jsonFactory, jsonRpcFactory);
    JsonObject actual = jsonRpcRequest.toJsonObject();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 53 with JsonObject

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

the class JsonRpcRequestTest method shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams.

@Test
public void shouldToStringWhenPassStringParamsWithoutIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(true);
    JsonObject expected = request;
    expected.remove("params");
    expected.remove("id");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("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 54 with JsonObject

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

the class JsonRpcRequestTest method setUp.

@Before
public void setUp() throws Exception {
    when(jsonRpcFactory.createParams(anyString())).thenReturn(params);
    JsonObject params = jsonFactory.createObject();
    params.put("parameter", "value");
    when(this.params.toJsonValue()).thenReturn(params);
    when(this.params.toString()).thenReturn(params.toJson());
    request = jsonFactory.createObject();
    request.put("jsonrpc", "2.0");
    request.put("method", "method");
    request.put("params", params);
    request.put("id", "0");
}
Also used : JsonObject(elemental.json.JsonObject) Before(org.junit.Before)

Example 55 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenParseStringParamsWithIdAndWithoutParams.

@Test
public void shouldToJsonObjectWhenParseStringParamsWithIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    expected.remove("params");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toJson(), jsonFactory, jsonRpcFactory);
    JsonObject actual = jsonRpcRequest.toJsonObject();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonObject (elemental.json.JsonObject)70 Test (org.junit.Test)49 JsonValue (elemental.json.JsonValue)19 JsonArray (elemental.json.JsonArray)14 JsonString (elemental.json.JsonString)5 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)5 ArrayList (java.util.ArrayList)4 Matchers.anyString (org.mockito.Matchers.anyString)4 Promise (org.eclipse.che.api.promises.client.Promise)3 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 JsonException (elemental.json.JsonException)2 List (java.util.List)2 Map (java.util.Map)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 StateComponent (org.eclipse.che.ide.api.component.StateComponent)2 EditorPartStack (org.eclipse.che.ide.api.parts.EditorPartStack)2 Perspective (org.eclipse.che.ide.api.parts.Perspective)2 Before (org.junit.Before)2 ArrayOf (elemental.util.ArrayOf)1