Search in sources :

Example 56 with JsonObject

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

the class JsonRpcRequestTest method shouldToStringWhenParseStringParamsWithoutIdAndWithParams.

@Test
public void shouldToStringWhenParseStringParamsWithoutIdAndWithParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    expected.remove("id");
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(request.toJson(), jsonFactory, jsonRpcFactory);
    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 57 with JsonObject

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

the class JsonRpcParamsTest method shouldToStringForParsedListDtoParams.

@Test
public void shouldToStringForParsedListDtoParams() throws Exception {
    JsonArray array = jsonFactory.createArray();
    JsonObject jsonObject = jsonFactory.parse(DTO_JSON);
    array.set(0, jsonObject);
    String expected = array.toJson();
    JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + DTO_JSON + "]", jsonFactory, dtoFactory);
    String actual = jsonRpcParams.toString();
    assertEquals(expected, actual);
}
Also used : JsonArray(elemental.json.JsonArray) JsonObject(elemental.json.JsonObject) JsonString(elemental.json.JsonString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 58 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithParams.

@Test
public void shouldToJsonObjectWhenParseStringParamsWithoutIdAndWithParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    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 59 with JsonObject

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenPassStringParamsWithoutIdAndWithoutParams.

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

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

the class JsonRpcRequestTest method shouldToJsonObjectWhenPassStringParamsWithIdAndWithParams.

@Test
public void shouldToJsonObjectWhenPassStringParamsWithIdAndWithParams() {
    when(params.emptyOrAbsent()).thenReturn(false);
    JsonObject expected = request;
    JsonRpcRequest jsonRpcRequest = new JsonRpcRequest("0", "method", params, jsonFactory);
    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