Search in sources :

Example 16 with JsonArray

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

the class JsonRpcListTest method shouldToJsonArrayParsedDtoArray.

@Test
public void shouldToJsonArrayParsedDtoArray() 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);
    JsonArray actual = jsonRpcList.toJsonArray();
    assertTrue(array.jsEquals(actual));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 17 with JsonArray

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

the class JsonRpcListTest method shouldToStringCreatedBooleanArray.

@Test
public void shouldToStringCreatedBooleanArray() throws Exception {
    JsonArray array = jsonFactory.createArray();
    array.set(0, false);
    JsonRpcList jsonRpcList = new JsonRpcList(singletonList(false), jsonFactory, dtoFactory);
    assertEquals(array.toJson(), jsonRpcList.toString());
}
Also used : JsonArray(elemental.json.JsonArray) Test(org.junit.Test)

Example 18 with JsonArray

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

the class JsonRpcListTest method shouldToStringifiedListParsedStringArray.

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

Example 19 with JsonArray

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

the class JsonRpcListTest method shouldToListParsedStringArray.

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

Example 20 with JsonArray

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

the class JsonRpcListTest method shouldParseNumberArray.

@Test
public void shouldParseNumberArray() throws Exception {
    Double expected = 0D;
    JsonArray array = jsonFactory.createArray();
    array.set(0, expected);
    String message = array.toJson();
    JsonRpcList jsonRpcList = new JsonRpcList(message, jsonFactory, dtoFactory);
    Double actual = jsonRpcList.get(0, Double.class);
    assertEquals(expected, actual);
}
Also used : JsonArray(elemental.json.JsonArray) 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