Search in sources :

Example 1 with StunnerEditor

use of org.kie.workbench.common.stunner.client.widgets.editor.StunnerEditor in project kie-wb-common by kiegroup.

the class AbstractProjectDiagramEditorTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    promises = new SyncPromises();
    when(versionRecordManager.getPathToLatest()).thenReturn(filePath);
    when(menuSessionItems.setErrorConsumer(Mockito.<Consumer>any())).thenReturn(menuSessionItems);
    when(menuSessionItems.setLoadingCompleted(Mockito.<Command>any())).thenReturn(menuSessionItems);
    when(menuSessionItems.setLoadingStarts(Mockito.<Command>any())).thenReturn(menuSessionItems);
    when(resourceType.getSuffix()).thenReturn("bpmn");
    when(resourceType.getShortName()).thenReturn("Business Process");
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(diagram.getName()).thenReturn(TITLE);
    when(metadata.getOverview()).thenReturn(overview);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.getContent()).thenReturn(mock(DefinitionSet.class));
    doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject();
    when(projectController.canUpdateProject(any())).thenReturn(promises.resolve(true));
    stunnerEditor = spy(new StunnerEditor(null, null, translationService, null, mock(ErrorPopupPresenter.class), stunnerEditorView) {

        @Override
        public ClientSession getSession() {
            return session;
        }

        @Override
        public CanvasHandler getCanvasHandler() {
            return canvasHandler;
        }

        @Override
        public Diagram getDiagram() {
            return diagram;
        }

        @Override
        public void setParsingExceptionProcessor(Consumer<DiagramParsingException> parsingExceptionProcessor) {
            AbstractProjectDiagramEditorTest.this.parsingExceptionProcessor = parsingExceptionProcessor;
            super.setParsingExceptionProcessor(parsingExceptionProcessor);
        }

        @Override
        public void setExceptionProcessor(Consumer<Throwable> exceptionProcessor) {
            AbstractProjectDiagramEditorTest.this.exceptionProcessor = exceptionProcessor;
            super.setExceptionProcessor(exceptionProcessor);
        }
    });
    doReturn(stunnerEditor).when(stunnerEditor).close();
    doNothing().when(stunnerEditor).showMessage(Mockito.anyString());
    doAnswer(invocation -> {
        ((Viewer.Callback) invocation.getArguments()[1]).onSuccess();
        return null;
    }).when(stunnerEditor).open(eq(diagram), Mockito.<SessionPresenter.SessionPresenterCallback>any());
    tested = spy(new AbstractProjectDiagramEditor(view, onDiagramFocusEvent, onDiagramLostFocusEvent, documentationView, resourceType, menuSessionItems, projectMessagesListener, translationService, projectDiagramServices, projectDiagramResourceServiceCaller, stunnerEditor) {

        {
            fileMenuBuilder = AbstractProjectDiagramEditorTest.this.fileMenuBuilder;
            projectController = AbstractProjectDiagramEditorTest.this.projectController;
            workbenchContext = AbstractProjectDiagramEditorTest.this.workbenchContext;
            versionRecordManager = AbstractProjectDiagramEditorTest.this.versionRecordManager;
            kieView = AbstractProjectDiagramEditorTest.this.kieView;
            overviewWidget = AbstractProjectDiagramEditorTest.this.overviewWidget;
            saveAndRenameCommandBuilder = AbstractProjectDiagramEditorTest.this.saveAndRenameCommandBuilder;
            changeTitleNotification = AbstractProjectDiagramEditorTest.this.changeTitleNotification;
            notification = AbstractProjectDiagramEditorTest.this.notification;
            savePopUpPresenter = AbstractProjectDiagramEditorTest.this.savePopUpPresenter;
            docks = AbstractProjectDiagramEditorTest.this.docks;
            perspectiveManager = AbstractProjectDiagramEditorTest.this.perspectiveManager;
        }

        @Override
        public String getEditorIdentifier() {
            return "testAbstractEditor";
        }
    });
}
Also used : ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) Consumer(java.util.function.Consumer) SyncPromises(org.uberfire.promise.SyncPromises) StunnerEditor(org.kie.workbench.common.stunner.client.widgets.editor.StunnerEditor) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet) ErrorPopupPresenter(org.uberfire.client.workbench.widgets.common.ErrorPopupPresenter) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) Before(org.junit.Before)

Aggregations

Consumer (java.util.function.Consumer)1 Before (org.junit.Before)1 StunnerEditor (org.kie.workbench.common.stunner.client.widgets.editor.StunnerEditor)1 SessionPresenter (org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter)1 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)1 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)1 ErrorPopupPresenter (org.uberfire.client.workbench.widgets.common.ErrorPopupPresenter)1 SyncPromises (org.uberfire.promise.SyncPromises)1