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