Search in sources :

Example 26 with JsonArray

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

the class JsonRpcParamsTest method shouldToStringCreatedListDoubleParams.

@Test
public void shouldToStringCreatedListDoubleParams() throws Exception {
    double value = 0D;
    List<Double> list = singletonList(value);
    JsonArray jsonArray = jsonFactory.createArray();
    jsonArray.set(0, value);
    String expected = jsonArray.toJson();
    JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonFactory, dtoFactory);
    String actual = jsonRpcParams.toString();
    assertEquals(expected, actual);
}
Also used : JsonArray(elemental.json.JsonArray) JsonString(elemental.json.JsonString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 27 with JsonArray

use of elemental.json.JsonArray 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 28 with JsonArray

use of elemental.json.JsonArray 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 29 with JsonArray

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

the class JsonRpcResultTest method shouldToStringWhenPassingParametersWithResultAsAListOfDto.

@Test
public void shouldToStringWhenPassingParametersWithResultAsAListOfDto() throws Exception {
    JsonArray array = jsonFactory.createArray();
    JsonObject value = jsonFactory.parse(dto.toString());
    array.set(0, value);
    String expected = array.toJson();
    JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(dto), jsonFactory, dtoFactory);
    String actual = jsonRpcResult.toString();
    assertEquals(expected, actual);
}
Also used : JsonArray(elemental.json.JsonArray) JsonObject(elemental.json.JsonObject) JsonString(elemental.json.JsonString) Test(org.junit.Test)

Example 30 with JsonArray

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

the class JsonRpcResultTest method shouldToStringWhenPassingParametersWithResultAsAListOfString.

@Test
public void shouldToStringWhenPassingParametersWithResultAsAListOfString() throws Exception {
    String value = "a";
    JsonArray array = jsonFactory.createArray();
    array.set(0, value);
    String expected = array.toJson();
    JsonRpcResult jsonRpcResult = new JsonRpcResult(singletonList(value), jsonFactory, dtoFactory);
    String actual = jsonRpcResult.toString();
    assertEquals(expected, actual);
}
Also used : JsonArray(elemental.json.JsonArray) JsonString(elemental.json.JsonString) Test(org.junit.Test)

Aggregations

JsonArray (elemental.json.JsonArray)69 Test (org.junit.Test)62 JsonValue (elemental.json.JsonValue)23 JsonString (elemental.json.JsonString)19 JsonObject (elemental.json.JsonObject)14 Matchers.anyString (org.mockito.Matchers.anyString)10 JsonNumber (elemental.json.JsonNumber)5 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Node (org.eclipse.che.ide.api.data.tree.Node)2 ResourceNode (org.eclipse.che.ide.resources.tree.ResourceNode)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Promise (org.eclipse.che.api.promises.client.Promise)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 Path (org.eclipse.che.ide.resource.Path)1 MessageLoader (org.eclipse.che.ide.ui.loaders.request.MessageLoader)1 Ignore (org.junit.Ignore)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1