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();
}
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);
}
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();
}
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));
}
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();
}
Aggregations