Search in sources :

Example 36 with JsonArray

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

the class AbstractPerspectivePersistenceTest method shouldRestoreOpenedParts.

@Test
//TODO
@Ignore
public void shouldRestoreOpenedParts() throws Exception {
    JsonObject state = Json.createObject();
    JsonObject parts = Json.createObject();
    state.put("PART_STACKS", parts);
    JsonObject partStack = Json.createObject();
    parts.put("INFORMATION", partStack);
    JsonArray partsArray = Json.createArray();
    partStack.put("PARTS", partsArray);
    JsonObject part = Json.createObject();
    partsArray.set(0, part);
    part.put("CLASS", "foo.Bar");
    when(dynaProvider.<PartPresenter>getProvider(anyString())).thenReturn(partProvider);
    when(partProvider.get()).thenReturn(partPresenter);
    perspective.loadState(state);
    verify(dynaProvider).getProvider("foo.Bar");
    verify(partProvider).get();
    verify(partStackPresenter).addPart(partPresenter);
}
Also used : JsonArray(elemental.json.JsonArray) JsonObject(elemental.json.JsonObject) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 37 with JsonArray

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

the class JsonRpcListTest method shouldParseBooleanArray.

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

Example 38 with JsonArray

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

the class JsonRpcListTest method shouldToJsonArrayCreatedDtoArray.

@Test
public void shouldToJsonArrayCreatedDtoArray() throws Exception {
    Dto dto = mock(Dto.class);
    when(dto.toString()).thenReturn(DTO);
    when(dto.getParameter()).thenReturn("value");
    when(dtoFactory.createDtoFromJson(DTO, Dto.class)).thenReturn(dto);
    JsonArray expected = jsonFactory.createArray();
    JsonValue parse = jsonFactory.parse(dto.toString());
    expected.set(0, parse);
    JsonRpcList jsonRpcList = new JsonRpcList(singletonList(dto), jsonFactory, dtoFactory);
    JsonArray actual = jsonRpcList.toJsonArray();
    assertTrue(expected.jsEquals(actual));
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 39 with JsonArray

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

the class JsonRpcListTest method shouldParseDtoArray.

@Test
public void shouldParseDtoArray() 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);
    Dto actual = jsonRpcList.get(0, Dto.class);
    assertEquals(expected.getParameter(), actual.getParameter());
}
Also used : JsonArray(elemental.json.JsonArray) JsonValue(elemental.json.JsonValue) Test(org.junit.Test)

Example 40 with JsonArray

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

the class JsonRpcListTest method shouldToStringifiedListParsedNumberArray.

@Test
public void shouldToStringifiedListParsedNumberArray() throws Exception {
    Double expected = 0D;
    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(expected, Double.valueOf(actual.iterator().next()));
}
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