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