Search in sources :

Example 16 with JsonObject

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

the class EditorAgentImpl method storeEditors.

private JsonObject storeEditors(EditorMultiPartStackState splitStacks) {
    JsonObject result = Json.createObject();
    if (splitStacks.getEditorPartStack() != null) {
        result.put("FILES", storeEditors(splitStacks.getEditorPartStack()));
    } else {
        result.put("DIRECTION", splitStacks.getDirection().toString());
        result.put("SPLIT_FIRST", storeEditors(splitStacks.getSplitFirst()));
        result.put("SPLIT_SECOND", storeEditors(splitStacks.getSplitSecond()));
        result.put("SIZE", splitStacks.getSize());
    }
    return result;
}
Also used : JsonObject(elemental.json.JsonObject)

Example 17 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenPassStringParamsWithoutIdAndWithParams.

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

Example 18 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithoutParams.

@Test
public void shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithoutParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    expected.remove("params");
    expected.remove("id");
    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 19 with JsonObject

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

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

the class JsonRpcResponseTest method setUp.

@Before
public void setUp() throws Exception {
    response = jsonFactory.createObject();
    JsonObject error = jsonFactory.createObject();
    JsonObject result = jsonFactory.createObject();
    error.put("code", 0);
    error.put("message", "error message");
    response.put("jsonrpc", "2.0");
    response.put("id", "0");
    response.put("error", error);
    response.put("result", result);
    when(this.result.toJsonValue()).thenReturn(result);
    when(this.error.toJsonObject()).thenReturn(error);
}
Also used : JsonObject(elemental.json.JsonObject) Before(org.junit.Before)

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