Search in sources :

Example 1 with ViewerSession

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

the class DMNDiagramsSessionTest method testLoadHistoryForTheCurrentDiagram_WhenItIsNotEditorSession.

@Test
public void testLoadHistoryForTheCurrentDiagram_WhenItIsNotEditorSession() {
    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 ViewerSession viewerSession = mock(ViewerSession.class);
    final Optional<ClientSession> optionalViewerSession = Optional.of(viewerSession);
    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(optionalViewerSession).when(dmnDiagramsSession).getCurrentSession();
    when(storedRedoHistory.containsKey(diagramId)).thenReturn(true);
    when(storedUndoHistory.containsKey(diagramId)).thenReturn(true);
    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, never()).notifyRegistryChanged();
    verify(undoCommandRegistry, never()).clear();
    verify(redoCommandRegistry, never()).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) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ViewerSession(org.kie.workbench.common.stunner.core.client.session.impl.ViewerSession) Test(org.junit.Test)

Aggregations

Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 Test (org.junit.Test)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)1 ClientSession (org.kie.workbench.common.stunner.core.client.session.ClientSession)1 ViewerSession (org.kie.workbench.common.stunner.core.client.session.impl.ViewerSession)1 Command (org.kie.workbench.common.stunner.core.command.Command)1