Search in sources :

Example 6 with EditorSession

use of org.kie.workbench.common.stunner.core.client.session.impl.EditorSession in project kie-wb-common by kiegroup.

the class DMNDiagramsSessionTest method testLoadHistoryForTheCurrentDiagram_WhenThereIsNotHistoryStored.

@Test
public void testLoadHistoryForTheCurrentDiagram_WhenThereIsNotHistoryStored() {
    final Map<String, List<Command<AbstractCanvasHandler, CanvasViolation>>> storedRedoHistory = mock(Map.class);
    final Map<String, List<Command<AbstractCanvasHandler, CanvasViolation>>> storedUndoHistory = mock(Map.class);
    final String diagramId = "diagramId";
    final EditorSession editorSession = mock(EditorSession.class);
    final Optional<EditorSession> optionalEditorSession = Optional.of(editorSession);
    final Registry<Command<AbstractCanvasHandler, CanvasViolation>> undoCommandRegistry = mock(Registry.class);
    final Registry<Command<AbstractCanvasHandler, CanvasViolation>> redoCommandRegistry = mock(Registry.class);
    final List<Command<AbstractCanvasHandler, CanvasViolation>> redoHistory = mock(List.class);
    final List<Command<AbstractCanvasHandler, CanvasViolation>> undoHistory = mock(List.class);
    doReturn(storedRedoHistory).when(dmnDiagramsSession).getStoredRedoHistories();
    doReturn(storedUndoHistory).when(dmnDiagramsSession).getStoredUndoHistories();
    doReturn(diagramId).when(dmnDiagramsSession).getCurrentDiagramId();
    doReturn(optionalEditorSession).when(dmnDiagramsSession).getCurrentSession();
    when(storedRedoHistory.containsKey(diagramId)).thenReturn(false);
    when(storedUndoHistory.containsKey(diagramId)).thenReturn(false);
    when(editorSession.getCommandRegistry()).thenReturn(undoCommandRegistry);
    when(editorSession.getRedoCommandRegistry()).thenReturn(redoCommandRegistry);
    when(storedRedoHistory.get(diagramId)).thenReturn(redoHistory);
    when(storedUndoHistory.get(diagramId)).thenReturn(undoHistory);
    doNothing().when(dmnDiagramsSession).loadHistoryToTheRegistry(redoHistory, redoCommandRegistry);
    doNothing().when(dmnDiagramsSession).loadHistoryToTheRegistry(undoHistory, undoCommandRegistry);
    dmnDiagramsSession.loadHistoryForTheCurrentDiagram();
    verify(dmnDiagramsSession, never()).loadHistoryToTheRegistry(redoHistory, redoCommandRegistry);
    verify(dmnDiagramsSession, never()).loadHistoryToTheRegistry(undoHistory, undoCommandRegistry);
    verify(dmnDiagramsSession).notifyRegistryChanged();
    verify(undoCommandRegistry).clear();
    verify(redoCommandRegistry).clear();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Command(org.kie.workbench.common.stunner.core.command.Command) Arrays.asList(java.util.Arrays.asList) List(java.util.List) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) Test(org.junit.Test)

Example 7 with EditorSession

use of org.kie.workbench.common.stunner.core.client.session.impl.EditorSession in project kie-wb-common by kiegroup.

the class DMNDiagramsSessionTest method testStoreCurrentRegistryHistory.

@Test
public void testStoreCurrentRegistryHistory() {
    final Map<String, List<Command<AbstractCanvasHandler, CanvasViolation>>> storedRedoHistory = mock(Map.class);
    final Map<String, List<Command<AbstractCanvasHandler, CanvasViolation>>> storedUndoHistory = mock(Map.class);
    final String diagramId = "diagramId";
    final EditorSession editorSession = mock(EditorSession.class);
    final Optional<EditorSession> optionalEditorSession = Optional.of(editorSession);
    final List<Command<AbstractCanvasHandler, CanvasViolation>> undoHistory = mock(List.class);
    final List<Command<AbstractCanvasHandler, CanvasViolation>> redoHistory = mock(List.class);
    final Registry<Command<AbstractCanvasHandler, CanvasViolation>> undoCommandRegistry = mock(Registry.class);
    final Registry<Command<AbstractCanvasHandler, CanvasViolation>> redoCommandRegistry = mock(Registry.class);
    doReturn(storedRedoHistory).when(dmnDiagramsSession).getStoredRedoHistories();
    doReturn(storedUndoHistory).when(dmnDiagramsSession).getStoredUndoHistories();
    doReturn(diagramId).when(dmnDiagramsSession).getCurrentDiagramId();
    doReturn(optionalEditorSession).when(dmnDiagramsSession).getCurrentSession();
    when(editorSession.getCommandRegistry()).thenReturn(undoCommandRegistry);
    when(editorSession.getRedoCommandRegistry()).thenReturn(redoCommandRegistry);
    when(undoCommandRegistry.getHistory()).thenReturn(undoHistory);
    when(redoCommandRegistry.getHistory()).thenReturn(redoHistory);
    dmnDiagramsSession.storeCurrentRegistryHistory();
    verify(storedUndoHistory).put(diagramId, undoHistory);
    verify(storedRedoHistory).put(diagramId, redoHistory);
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Command(org.kie.workbench.common.stunner.core.command.Command) Arrays.asList(java.util.Arrays.asList) List(java.util.List) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) Test(org.junit.Test)

Example 8 with EditorSession

use of org.kie.workbench.common.stunner.core.client.session.impl.EditorSession in project kie-wb-common by kiegroup.

the class AbstractCanvasShortcutsControlImplTest method testRegisterCauseCanvasFocus.

@Test
public void testRegisterCauseCanvasFocus() {
    final EditorSession session = mock(EditorSession.class);
    final KeyboardControl keyboardControl = mock(KeyboardControl.class);
    doReturn(canvas).when(session).getCanvas();
    doReturn(keyboardControl).when(session).getKeyboardControl();
    canvasShortcutsControl.bind(session);
    final Element element = mock(Element.class);
    canvasShortcutsControl.register(element);
    // Ensure never focus the canvas here, as it's probably not initialized yet, at least in IE11,
    // so the focus will fail at runtime. See RHPAM-1681.
    verify(canvas, never()).focus();
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) Test(org.junit.Test)

Example 9 with EditorSession

use of org.kie.workbench.common.stunner.core.client.session.impl.EditorSession in project kie-wb-common by kiegroup.

the class AbstractCanvasShortcutsControlImplTest method testBind.

@Test
public void testBind() {
    assertThat(canvasShortcutsControl.editorSession).isNull();
    final EditorSession session = mock(EditorSession.class);
    final KeyboardControl keyboardControl = mock(KeyboardControl.class);
    doReturn(keyboardControl).when(session).getKeyboardControl();
    canvasShortcutsControl.bind(session);
    assertThat(canvasShortcutsControl.editorSession).isEqualTo(session);
    verify(keyboardControl).addKeyShortcutCallback(eq(canvasShortcutsControl));
}
Also used : EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) Test(org.junit.Test)

Example 10 with EditorSession

use of org.kie.workbench.common.stunner.core.client.session.impl.EditorSession in project kie-wb-common by kiegroup.

the class DMNDiagramEditorTest method testOpenDock.

@Test
public void testOpenDock() {
    final EditorSession session = mock(EditorSession.class);
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    editor.openDock();
    verify(decisionNavigatorDock).open();
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) DMNEditorSession(org.kie.workbench.common.dmn.client.session.DMNEditorSession) Test(org.junit.Test)

Aggregations

EditorSession (org.kie.workbench.common.stunner.core.client.session.impl.EditorSession)13 Test (org.junit.Test)6 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)6 Arrays.asList (java.util.Arrays.asList)3 List (java.util.List)3 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)3 Command (org.kie.workbench.common.stunner.core.command.Command)3 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)3 RenderMode (org.kie.workbench.common.forms.dynamic.service.shared.RenderMode)2 Element (org.kie.workbench.common.stunner.core.graph.Element)2 Path (org.uberfire.backend.vfs.Path)2 ArrayList (java.util.ArrayList)1 DMNEditorSession (org.kie.workbench.common.dmn.client.session.DMNEditorSession)1 SessionFocusedEvent (org.kie.workbench.common.stunner.client.widgets.event.SessionFocusedEvent)1 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)1 SelectionControl (org.kie.workbench.common.stunner.core.client.canvas.controls.SelectionControl)1 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 DomainObject (org.kie.workbench.common.stunner.core.domainobject.DomainObject)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1