Search in sources :

Example 6 with JsonArray

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

the class JsonRpcListTest method shouldToJsonArrayCreatedStringArray.

@Test
public void shouldToJsonArrayCreatedStringArray() throws Exception {
    JsonArray expected = jsonFactory.createArray();
    expected.set(0, "a");
    JsonRpcList jsonRpcList = new JsonRpcList(singletonList("a"), jsonFactory, dtoFactory);
    JsonArray actual = jsonRpcList.toJsonArray();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonArray(elemental.json.JsonArray) Test(org.junit.Test)

Example 7 with JsonArray

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

the class JsonRpcListTest method shouldToStringArrayParsedStringArray.

@Test
public void shouldToStringArrayParsedStringArray() throws Exception {
    String expected = "a";
    JsonArray array = jsonFactory.createArray();
    array.set(0, expected);
    String message = array.toJson();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
    String actual = jsonRpcList.toString();
    assertEquals(message, actual);
}
Also used : JsonArray(elemental.json.JsonArray) Test(org.junit.Test)

Example 8 with JsonArray

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

the class JsonRpcListTest method shouldToStringArrayParsedDtoArray.

@Test
public void shouldToStringArrayParsedDtoArray() 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);
    String actual = jsonRpcList.toString();
    assertEquals(message, actual);
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 9 with JsonArray

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

the class JsonRpcListTest method shouldToListParsedBooleanArray.

@Test
public void shouldToListParsedBooleanArray() throws Exception {
    Boolean expected = false;
    JsonArray array = jsonFactory.createArray();
    array.set(0, expected);
    String message = array.toJson();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
    List<Boolean> actual = jsonRpcList.toList(Boolean.class);
    assertEquals(singletonList(expected), actual);
}
Also used : JsonArray(elemental.json.JsonArray) Test(org.junit.Test)

Example 10 with JsonArray

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

the class JsonRpcParamsTest method shouldToJsonValueForParsedListBooleanParams.

@Test
public void shouldToJsonValueForParsedListBooleanParams() throws Exception {
    Boolean expected = false;
    JsonArray array = jsonFactory.createArray();
    array.set(0, expected);
    JsonRpcParams jsonRpcParams = new JsonRpcParams("[" + expected + "]", jsonFactory, dtoFactory);
    JsonValue jsonValue = jsonRpcParams.toJsonValue();
    assertTrue(array.jsEquals(jsonValue));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) 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