Search in sources :

Example 6 with JsonObject

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

the class AppStateManagerTest method shouldStoreStateByWsId.

@Test
public void shouldStoreStateByWsId() throws Exception {
    appStateManager.persistWorkspaceState(WS_ID);
    verify(preferencesManager).setValue(preferenceArgumentCaptor.capture(), jsonArgumentCaptor.capture());
    assertThat(preferenceArgumentCaptor.getValue()).isNotNull();
    assertThat(preferenceArgumentCaptor.getValue()).isNotNull();
    JsonObject object = Json.parse(jsonArgumentCaptor.getValue());
    assertThat(object.hasKey(WS_ID)).isTrue();
}
Also used : JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 7 with JsonObject

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

the class AbstractPerspectivePersistenceTest method shouldNotStoreEditorPartStack.

@Test
public void shouldNotStoreEditorPartStack() throws Exception {
    JsonObject state = perspective.getState();
    JsonObject partStacks = state.getObject("PART_STACKS");
    String[] keys = partStacks.keys();
    assertThat(keys).containsOnly("INFORMATION", "NAVIGATION", "TOOLING");
}
Also used : JsonObject(elemental.json.JsonObject) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 8 with JsonObject

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

the class WorkspacePresenterPersistenceTest method shouldStorePerspectives.

@Test
public void shouldStorePerspectives() throws Exception {
    when(perspective1.getState()).thenReturn(Json.createObject());
    when(perspective2.getState()).thenReturn(Json.createObject());
    JsonObject state = presenter.getState();
    JsonObject perspectives = state.getObject("perspectives");
    assertThat(perspectives).isNotNull();
    assertThat(perspectives.getObject("perspective1")).isNotNull();
}
Also used : JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 9 with JsonObject

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

the class WorkspacePresenterPersistenceTest method shouldRestoreStorePerspectives.

@Test
public void shouldRestoreStorePerspectives() throws Exception {
    JsonObject state = Json.createObject();
    state.put("currentPerspectiveId", "perspective2");
    JsonObject perspectives = Json.createObject();
    state.put("perspectives", perspectives);
    JsonObject perspective1State = Json.createObject();
    perspectives.put("perspective1", perspective1State);
    presenter.loadState(state);
    verify(perspective1).loadState(perspective1State);
}
Also used : JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 10 with JsonObject

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

the class AbstractPerspective method getState.

@Override
public JsonObject getState() {
    JsonObject state = Json.createObject();
    JsonObject partStacks = Json.createObject();
    state.put("ACTIVE_PART", activePart.getClass().getName());
    state.put("PART_STACKS", partStacks);
    partStacks.put(PartStackType.INFORMATION.name(), getPartStackState(this.partStacks.get(INFORMATION), belowPartController));
    partStacks.put(PartStackType.NAVIGATION.name(), getPartStackState(this.partStacks.get(NAVIGATION), leftPartController));
    partStacks.put(PartStackType.TOOLING.name(), getPartStackState(this.partStacks.get(TOOLING), rightPartController));
    return state;
}
Also used : JsonObject(elemental.json.JsonObject)

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